I am using Pivot and PivotItem from Office UI Fabric to display my content in tabs. Currently when the tab renders, all the tabs are left aligned.
I need to display the tabs with equal width so that they occupy the 100% width of the page.
Below is the code for Pivot.
<Pivot linkFormat={PivotLinkFormat.tabs} linkSize={PivotLinkSize.large} styles={pivotStyles}>
<PivotItem headerText="Foo">
<Label>Pivot #1</Label>
</PivotItem>
<PivotItem headerText="Bar">
<Label>Pivot #2</Label>
</PivotItem>
<PivotItem headerText="Bas">
<Label>Pivot #3</Label>
</PivotItem>
<PivotItem headerText="Biz">
<Label>Pivot #4</Label>
</PivotItem>
</Pivot>
Below is the code that I could figure out to add styles to Pivot. But we do not have styles attribute for PivotItem.
const pivotStyles:IPivotStyles = {
link: {},
linkContent: {},
linkIsSelected: {},
text: {},
icon: {},
count: {},
root: {
//background: DefaultPalette.greenDark
}
};
How can I apply style to PivotItem so that I can add width to it?
PivotItem styles could be adjusted via Pivot.styles property, at least the following styles could be set:
link
linkContent
linkIsSelected
Example
The following example demonstrates how to set fixed width for pivot link:
const pivotStyles: Partial<IStyleSet<IPivotStyles>> = {
link: {
width: "300px"
},
linkIsSelected: {
width: "300px"
}
};
where
const tabsItems = [
{
content: "Pivot #1",
header: "My Files"
},
{
content: "Pivot #2",
header: "Recent"
},
{
content: "Pivot #3",
header: "Shared with me"
}
];
export const PivotBasicExample: React.FunctionComponent = () => {
return (
<Pivot styles={pivotStyles}>
{tabsItems.map((tabItem,idx) => (
<PivotItem key={idx} headerText={tabItem.header}>
<Label>{tabItem.content}</Label>
</PivotItem>
))}
</Pivot>
);
};
Related
I have createMaterialTopTabNavigator in my app with three tabs. These three tabs themselves belong to different createStackNavigators. I have passed drawer icon as my header right to createMaterialTopTabNavigator.
I want to edit the background color of createMaterialTopTabNavigator tabs but it is getting override with my HeaderRight icon styling.
const Daily = createStackNavigator(
{
Daily: {
screen: DailyStack,
},
Another:{
screen: Another,
}
},
{
headerMode:'none'
},
);
const Monthly = createStackNavigator({
Monthly: {
screen: MonthlyStack,
},
},
{
headerMode:'none'
});
const Range = createStackNavigator({
Range: {
screen: RangeStack,
}
},
{
headerMode:'none'
});
const DashboardTabNavigator = createMaterialTopTabNavigator(
{
Daily,
Monthly,
Range
},
{
navigationOptions: ({ navigation }) => {
return {
// tabBarOptions:{
// indicatorStyle: {
// backgroundColor: "#2E86C1",
// },
// // tabStyle:{
// // backgroundColor: '#F7F9F9'
// // },
// labelStyle :{
// color: '#2E86C1'
// },
// activeTintColor:'blue',
// inactiveTintColor: {
// color: 'green'
// },
// style: {
// backgroundColor: 'white',
// elevation: 0, // remove shadow on Android
// shadowOpacity: 0, // remove shadow on iOS,
// borderWidth:1,
// borderColor:'#ccc'
// }
// },
headerRight: (
<Icon style={{ paddingRight:20 }} onPress={() => navigation.openDrawer()} name="menu" color='#000' size={30} />
)
};
}
}
)
If I am passing the styling options inside navigationOptions then the styling does not works; only HeaderRight shows, and if I pass the styling options outside the navigationOptions, the styling works but then it hides the HeaderRight Icon from right
you must entirely study this link.
another important subject is that navigationOptions related to every screen in stack. such as this:
const App = createMaterialTopTabNavigator({
TabScreen: {
screen: TabScreen,
navigationOptions: {
headerStyle: {
backgroundColor: '#633689',
},
headerTintColor: '#FFFFFF',
title: 'TabExample',
},
},
});
so if you want to set style for top tab bar, you must use defaultNavigationOptions property such as this:
const DashboardTabNavigator = createMaterialTopTabNavigator(
{
Daily,
Monthly,
Range
},
{
defaultNavigationOptions: ({ navigation }) => {
return {
tabBarOptions:{
style: {
backgroundColor: 'white',
elevation: 0, // remove shadow on Android
shadowOpacity: 0, // remove shadow on iOS,
borderWidth:1,
borderColor:'#ccc'
}
},
};
}
}
)
Sharing common navigationOptions across screens
It is common to want to configure the header in a similar way across many screens. For example, your company brand color might be red and so you want the header background color to be red and tint color to be white. Conveniently, these are the colors we're using in our running example, and you'll notice that when you navigate to the DetailsScreen the colors go back to the defaults. Wouldn't it be awful if we had to copy the navigationOptions header style properties from HomeScreen to DetailsScreen, and for every single screen component we use in our app? Thankfully, we do not. We can instead move the configuration up to the stack navigator under the property defaultNavigationOptions.
I have built two widgets in Apostrophe CMS :
Multi-Column Widget which has the flexbox class applied and serves up an Add-column widget which in turn serves up richtext, etc that is intended to flex out with however many Add-Columns inserted into the Multi-Column widget. Problem is it all gets a bit funky. The editor UI goes a bit insane with a horizontal layout, drag and drop sometimes duplicates and looses content, you have to really try hard to understand what is being selected.
Is there any tools or tips on working with this type of layout?
index.js for multiple-column widget
======================================
module.exports = {
extend: 'apostrophe-widgets',
label: 'Multiple Column Layout',
contextualOnly: true,
addFields: [
{
name: 'multiColContainer',
type: 'area',
label: 'Multiple Column Container',
}
]
};
widget.html for multiple-column-widget
======================================
<div class="multiple-column">
{{ apos.area(data.widget, 'multiColContainer', {
widgets: {
'add-column': {}
}
}) }}
</div>
index.js for add-column-widget
==============================
module.exports = {
extend: 'apostrophe-widgets',
label: 'Add Column',
contextualOnly: true,
addFields: [
{
name: 'addColumn',
type: 'area',
label: 'Column',
}
]
};
widget.html for add-column-widget
=================================
<div class="add-column">
{{ apos.area(data.widget, 'addColumn', {
widgets: {
'apostrophe-images': {},
'link': {},
'apostrophe-video':{},
'apostrophe-rich-text': {
toolbar: [ 'Styles', 'Bold', 'Italic', 'Link', 'Unlink', 'Table', 'BulletedList', 'Blockquote', 'Strike', 'Subscript', 'Superscript'],
styles: [
{ name: 'Heading', element: 'h1' },
{ name: 'Subheading', element: 'h2' },
{ name: 'Title', element: 'h3' },
{ name: 'Small Title', element: 'h4' },
{ name: 'Paragraph', element: 'p' }
]
}
}
}) }}
</div>
changes to site.less for displaying flex and to help out during editing
=======================================================================
.multiple-column {
.apos-area-widgets, // proper context for logged-in user
.apos-area { // proper context for logged-out user
display: flex;
justify-content: space-around;
}
.apos-area-widget-wrapper {
flex-grow: 1;
flex-basis: 0;
}
}
// try and help to identify what is what
.multiple-column {
.apos-area-widgets{
:hover{border:1px dashed red;}
.add-column{
:hover{border:1px dashed greenyellow;}
}
}
}
I am using react-table in my application.
I am stuck in doing one thing i.e. changing the CSS of columns while a column is being resized.
Currently when you resize a column only cursor changes. What I want is to add border to the selected column.
I searched for this on SO and google as well. But couldn't find anything useful. And In the documentation as well nothing is mentioned about this topic as well.
Update
Now I am able to add border while dragging the column while resizing. I am able to do so by adding and removing the class.
What I did to do so:
Created a var in the state for className:
this.state = {
addBorder: null
}
Passed this class name in my column:
const columns = [{
Header: 'Name',
accessor: 'name', // String-based value accessors!,
headerClassName: this.state.addBorder,
className: this.state.addBorder
}, {
Header: 'Age',
accessor: 'age',
Cell: props => <span className='number'>{2}</span> // Custom cell components!
}, {
id: 'friendName', // Required because our accessor is not a string
Header: 'Friend Name',
accessor: d => d.friend.name // Custom value accessors!
}, {
Header: props => <span>Friend Age</span>, // Custom header components!
accessor: 'friend.age'
}];
return (
<div onMouseUp={this.handleMouseUp}>
<ReactTable
data={data}
columns={columns}
resizable={true}
onResizedChange={(col, e) => {
const column = col[col.length-1];
this.setState({addBorder: column.id})
}} />
</div>
)
}
To remove the class when dragging ends:
handleMouseUp (e) {
this.setState({addBorder: null});
}
But I am still not able to add border on hover.
Now, I am sending my custom HTML in header props. And in my HTML I have made an extra div. And I have moved this div to right. And on hover of this div, I am emitting mouse events and changing CSS accordingly.
But Existing div in the header that is responsible for resizing column is overlapping with my Div.
Header: props => <div className='header-div'> Name <div onMouseOver = {() => {
console.log('mose');
this.setState({className: 'addBorder'});
}} className='hover-div' onMouseOut = {() => {console.log('sdasd');this.setState({className: null});}}> </div></div> ,
From what I understand, you want to add some border when you hover over a column header. If my understanding is correct, you can use :hover pseudo selector over the header class
.hdrCls:hover {
border: 2px solid rgba(0,0,0,0.6) !important;
}
Update :
You can manipulate state in onResizedChange handler exposed by react-table
onResizedChange={(newResized, event) => {
let resizedCol = newResized.slice(-1)[0].id;
if(this.state.activeCol !== resizedCol) {
this.setState({
activeCol: resizedCol,
resizing: true
})
}
}}
Also, make sure you have to make the resizing state to false on mouseup event. For that I have come up with the below solution.
componentDidUpdate(props, state) {
if (this.state.resizing && !state.resizing) {
document.addEventListener('mouseup', this.onMouseUp);
} else if (!this.state.resizing && state.resizing) {
document.removeEventListener('mouseup', this.onMouseUp);
}
}
onMouseUp = (evt) => {
this.setState({
activeCol: '',
resizing: false
});
evt.stopPropagation();
evt.preventDefault();
}
For reference:
const ReactTable = window.ReactTable.default
class App extends React.Component {
constructor(props) {
super(props)
this.state = {
activeCol: '',
resizing: false
}
}
componentDidUpdate(props, state) {
if (this.state.resizing && !state.resizing) {
document.addEventListener('mouseup', this.onMouseUp);
} else if (!this.state.resizing && state.resizing) {
document.removeEventListener('mouseup', this.onMouseUp);
}
}
onMouseUp = (evt) => {
this.setState({
activeCol: '',
resizing: false
});
evt.stopPropagation();
evt.preventDefault();
}
render() {
const data = [{
name:"Mark",
age:24
},
{
name:"Derek",
age:26
}]
const columns = [{
Header: 'Name',
accessor: 'name', // String-based value accessors!,
headerClassName: 'hdrCls',
className: (this.state.activeCol === 'name') && this.state.resizing ? 'borderCellCls' : 'defaultCellCls'
}, {
Header: 'Age',
accessor: 'age',
headerClassName: 'hdrCls',
className: (this.state.activeCol === 'age') && this.state.resizing ? 'borderCellCls' : 'defaultCellCls'
}];
return <ReactTable
data = { data }
columns = { columns }
showPagination= {false}
onResizedChange={(newResized, event) => {
let resizedCol = newResized.slice(-1)[0].id;
if(this.state.activeCol !== resizedCol) {
this.setState({
activeCol: resizedCol,
resizing: true
})
}
}}
/>
}
}
ReactDOM.render( < App / > , document.getElementById("app"))
.hdrCls:hover {
border: 2px solid rgba(0,0,0,0.6) !important;
}
.borderCellCls {
border-right: 2px solid rgba(0,0,0,0.6) !important;
border-left: 2px solid rgba(0,0,0,0.6) !important;
}
.defaultCellCls {
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-table/6.7.6/react-table.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/react-table/6.7.6/react-table.css"></link>
<div id="app"></div>
You can play around with CSS. Hope this is what you want and hope this helps.
Update:
I think you have to play with CSS to achieve what you desire.
.borderCellCls {
border-right: 2px solid rgba(0,0,0,0.6) !important;
border-left: 2px solid rgba(0,0,0,0.6) !important;
}
If you are here to find out how to set className to a column cell (with the react-table), here is the solution:
1)
<tr
{...row.getRowProps()}
>
{row.cells.map((cell) => (
<td
{...cell.getCellProps([
{
className: cell.column.className, // pay attention to this
style: cell.column.style,
// set here your other custom props
},
])}
>
{cell.render('Cell')}
</td>
))}
</tr>
2)
const columns = React.useMemo(
() => [
{
Header: 'Date',
accessor: 'date',
minWidth: 70,
className: 'text-dark fw-bolder fs-6 min-w-70px', // pass className props here
headerClassName: 'text-muted', // or another props like this one
}]
<Table columns={columns} ... />
And finally, those props will be passed to your cells
For TypeScript support follow the instructions in DefinitelyTyped, ie. create the file /src/types/react-table-config.d.ts with the content from the instructions, then add the following to it to support custom properties on your column (add more properties in the last line as required):
// Added to support classes to template from:
// https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-table
export interface ColumnInstance<
D extends Record<string, unknown> = Record<string, unknown>
> extends Omit<ColumnInterface<D>, 'id'>,
ColumnInterfaceBasedOnValue<D>,
UseTableColumnProps<D>,
Record<headerClassName | className, string> {}
I'm trying to put an image background to my form panel, it doesn't display anything, I'm using the code in this tutoriel:
http://miamicoder.com/2012/adding-a-login-screen-to-a-sencha-touch-application-part-2/
here is my login view:
Ext.define('MyApp2.view.Login', {
extend: 'Ext.form.Panel',
alias: "widget.loginview",
requires: ['Ext.form.FieldSet', 'Ext.form.Password', 'Ext.Label', 'Ext.Img', 'Ext.util.DelayedTask'],
config: {
title: 'Login',
cls:'panelBackground',
// bodyStyle:'background-color:#fff;padding: 10px',
items: [
{
xtype: 'label',
html: 'Login failed. Please enter the correct credentials.',
itemId: 'signInFailedLabel',
hidden: true,
hideAnimation: 'fadeOut',
showAnimation: 'fadeIn',
style: 'color:#990000;margin:5px 0px;'
},
{
xtype: 'fieldset',
title: 'Login Example',
items: [
{
xtype: 'textfield',
placeHolder: 'Username',
itemId: 'userNameTextField',
name: 'userNameTextField',
required: true
},
{
xtype: 'passwordfield',
placeHolder: 'Password',
itemId: 'passwordTextField',
name: 'passwordTextField',
required: true
}
]
},
{
xtype: 'button',
itemId: 'logInButton',
ui: 'action',
padding: '10px',
text: 'Log In'
}
],
listeners: [{
delegate: '#logInButton',
event: 'tap',
fn: 'onLogInButtonTap'
}]
},
onLogInButtonTap: function() {
var me = this,
usernameField = me.down('#userNameTextField'),
passwordField = me.down('#passwordTextField'),
label = me.down('#signInFailedLabel'),
username = usernameField.getValue(),
password = passwordField.getValue();
label.hide();
// Using a delayed task in order to give the hide animation above
// time to finish before executing the next steps.
var task = Ext.create('Ext.util.DelayedTask', function() {
label.setHtml('');
me.fireEvent('signInCommand', me, username, password);
usernameField.setValue('');
passwordField.setValue('');
});
task.delay(500);
},
showSignInFailedMessage: function(message) {
var label = this.down('#signInFailedLabel');
label.setHtml(message);
label.show();
}
});
and my app.css:
.panelBackground
{
background-image: url(http://localhost:8383/MyApp2/resources/images/login.png) !important;
background-repeat: no-repeat !important;
background-size: 100% 100% !important;
}
Ps: I've tried to put it in the index.html, but it seems that nothing is changing, what I'm doing wrong?
The problem is Ext.form.Panel, it renders a scroll container above the background (You can check it in the Chrome Debugger). But i don't know how to disable that.
But when you change it to
Ext.define('MyApp2.view.Login', {
extend: 'Ext.Container',
alias: "widget.loginview",
the code is going to work.
I had a look on the rest of your code, there will be no problem when using a container instead of a form panel.
I am also using same code and tring to set image in background of panel but i am getting blank border on image.
I want to set image in full screen.
Is your images fitted on full screen if yes then please post your code.
I tried to get some custom css to customize my grid in ExtJS.
I was struggling with the cls input, but then I found an other way which worked.
What I want is to highlight a whole line regarding a value
Here is my code in the View :
Ext.define('AM.view.user.List' ,{
extend: 'Ext.grid.Panel',
alias: 'widget.userlist',
title: 'Test ',
store: 'Users',
initComponent: function() {
this.columns = [
{header: 'ID du CPE', width: 150, dataIndex: 'ID', flex: 0},
{header: 'Modèle', dataIndex: 'Modele', flex: 1},
{header: 'Firmware', dataIndex: 'firmware', flex: 1},
{header: 'Année MeS', dataIndex: 'annee', flex: 1},
{header: 'Alerte', dataIndex: 'statut', hidden: true, hideable: false, flex: 0},
{header: 'Etat', id:'CC', dataIndex: 'alerte', flex: 0, width: 100}
and there is my code in CSS :
.x-grid-table .x-grid-row-selected .x-grid-cell-CC {
background-color: #1DAE00 !important; }
.x-grid-table .x-grid-row-over .x-grid-cell-CC {
background-color: #1DAE00 !important; }
For the moment, it works (the id=CC creates the link with the css file).
When I pass my mouse over a line or click on a line, the value concerned in the column "Etat" are highlighted in green.
I tried the cls method but I didn't succeed to make it work.
The main reason, in all the tutorials I found, the classical way to do it is :
Ext.create('Ext.grid.Panel', {
cls: 'CC',
But in my case, I have :
Ext.define('AM.view.user.List' ,{
extend: 'Ext.grid.Panel',
and I don't know where to put the cls attribute. Itried several ways but I always end up with an error.
So here's my two questions :
1- how to highlights the whole line (not only a line from a single column)
2- how to automatically highlight a whole line regarding a value contained in this one ?
Sorry if it's not very clear :s.
You need to provide a getRowClass method in the grid's view configuration. Like this:
,viewConfig: {
getRowClass: function(record) {
return record.get('highlight')
? 'highlight'
: '';
}
}
Here's a complete example on how to do that in class extended from grid panel:
Ext.define('My.Grid', {
extend: 'Ext.grid.Panel'
,store: {
fields: ['foo', 'bar', 'highlight']
,proxy: {
type: 'memory'
,reader: 'array'
}
,data: [[1, 'Bar', false],[2, 'Baz', false],[3, 'Bat', true]]
}
,columns: [
{dataIndex: 'foo', text: "Foo"}
,{dataIndex: 'bar', text: "Bar"}
,{dataIndex: 'highlight', text: "Highlighted"}
]
,viewConfig: {
getRowClass: function(record) {
return record.get('highlight')
? 'highlight'
: '';
}
}
});
That would work with the follwing CSS rule. Note the selector to catch highlighted rows (.x-grid-row.highlight with no spaces), and the fact that the background is applied to background TD, not directly to the TR element, which would not work.
.x-grid-row.highlight .x-grid-td {
background-color: palegreen;
}
Thanks to rixo, here's the code which makes it work !
viewConfig: {
getRowClass: function(record) {
var red = record.get('statut') // shows if a CPE is dead or not (HS = Dead)
if (red == 'HS') {
return 'highlight'
}
}
},