application-amicale/native-base-theme/components/index.js

250 lines
5.4 KiB
JavaScript
Raw Normal View History

2020-01-28 20:07:21 +01:00
/* eslint-disable no-param-reassign */
2019-06-25 22:20:24 +02:00
// @flow
2020-01-28 20:07:21 +01:00
import _ from 'lodash';
import bodyTheme from './Body';
import leftTheme from './Left';
import rightTheme from './Right';
import headerTheme from './Header';
import switchTheme from './Switch';
import thumbnailTheme from './Thumbnail';
import containerTheme from './Container';
import contentTheme from './Content';
import buttonTheme from './Button';
import titleTheme from './Title';
import subtitleTheme from './Subtitle';
import inputGroupTheme from './InputGroup';
import badgeTheme from './Badge';
import checkBoxTheme from './CheckBox';
import cardTheme from './Card';
import radioTheme from './Radio';
import h3Theme from './H3';
import h2Theme from './H2';
import h1Theme from './H1';
import footerTheme from './Footer';
import footerTabTheme from './FooterTab';
import fabTheme from './Fab';
import itemTheme from './Item';
import labelTheme from './Label';
import textAreaTheme from './Textarea';
import textTheme from './Text';
import toastTheme from './Toast';
import tabTheme from './Tab';
import tabBarTheme from './TabBar';
import tabContainerTheme from './TabContainer';
import viewTheme from './View';
import tabHeadingTheme from './TabHeading';
import iconTheme from './Icon';
import inputTheme from './Input';
import swipeRowTheme from './SwipeRow';
import segmentTheme from './Segment';
import spinnerTheme from './Spinner';
import cardItemTheme from './CardItem';
import listItemTheme from './ListItem';
import formTheme from './Form';
import separatorTheme from './Separator';
import pickerTheme from './Picker';
import variable from './../variables/platform';
export default (variables /* : * */ = variable) => {
2019-06-25 22:20:24 +02:00
const theme = {
variables,
2020-01-28 20:07:21 +01:00
'NativeBase.Left': {
2019-06-25 22:20:24 +02:00
...leftTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
2019-06-25 22:20:24 +02:00
...rightTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Body': {
2019-06-25 22:20:24 +02:00
...bodyTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Header': {
2019-06-25 22:20:24 +02:00
...headerTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Button': {
2019-06-25 22:20:24 +02:00
...buttonTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Title': {
2019-06-25 22:20:24 +02:00
...titleTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Subtitle': {
2019-06-25 22:20:24 +02:00
...subtitleTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.InputGroup': {
2019-06-25 22:20:24 +02:00
...inputGroupTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Input': {
2019-06-25 22:20:24 +02:00
...inputTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Badge': {
2019-06-25 22:20:24 +02:00
...badgeTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.CheckBox': {
2019-06-25 22:20:24 +02:00
...checkBoxTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Radio': {
2019-06-25 22:20:24 +02:00
...radioTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Card': {
2019-06-25 22:20:24 +02:00
...cardTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.CardItem': {
2019-06-25 22:20:24 +02:00
...cardItemTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Toast': {
2019-06-25 22:20:24 +02:00
...toastTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.H1': {
2019-06-25 22:20:24 +02:00
...h1Theme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.H2': {
2019-06-25 22:20:24 +02:00
...h2Theme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.H3': {
2019-06-25 22:20:24 +02:00
...h3Theme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Form': {
2019-06-25 22:20:24 +02:00
...formTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Container': {
2019-06-25 22:20:24 +02:00
...containerTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Content': {
2019-06-25 22:20:24 +02:00
...contentTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Footer': {
2019-06-25 22:20:24 +02:00
...footerTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Tabs': {
2019-06-25 22:20:24 +02:00
flex: 1
},
2020-01-28 20:07:21 +01:00
'NativeBase.FooterTab': {
2019-06-25 22:20:24 +02:00
...footerTabTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.ListItem': {
2019-06-25 22:20:24 +02:00
...listItemTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.ListItem1': {
2019-06-25 22:20:24 +02:00
...listItemTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
...iconTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
...iconTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
...textTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Spinner': {
2019-06-25 22:20:24 +02:00
...spinnerTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Fab': {
2019-06-25 22:20:24 +02:00
...fabTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Item': {
2019-06-25 22:20:24 +02:00
...itemTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Label': {
2019-06-25 22:20:24 +02:00
...labelTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Textarea': {
2019-06-25 22:20:24 +02:00
...textAreaTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.PickerNB': {
2019-06-25 22:20:24 +02:00
...pickerTheme(variables),
2020-01-28 20:07:21 +01:00
'NativeBase.Button': {
'NativeBase.Text': {}
2019-06-25 22:20:24 +02:00
}
},
2020-01-28 20:07:21 +01:00
'NativeBase.Tab': {
2019-06-25 22:20:24 +02:00
...tabTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Segment': {
2019-06-25 22:20:24 +02:00
...segmentTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.TabBar': {
2019-06-25 22:20:24 +02:00
...tabBarTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.ViewNB': {
2019-06-25 22:20:24 +02:00
...viewTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.TabHeading': {
2019-06-25 22:20:24 +02:00
...tabHeadingTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.TabContainer': {
2019-06-25 22:20:24 +02:00
...tabContainerTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Switch': {
2019-06-25 22:20:24 +02:00
...switchTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Separator': {
2019-06-25 22:20:24 +02:00
...separatorTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.SwipeRow': {
2019-06-25 22:20:24 +02:00
...swipeRowTheme(variables)
},
2020-01-28 20:07:21 +01:00
'NativeBase.Thumbnail': {
2019-06-25 22:20:24 +02:00
...thumbnailTheme(variables)
}
};
const cssifyTheme = (grandparent, parent, parentKey) => {
_.forEach(parent, (style, styleName) => {
if (
2020-01-28 20:07:21 +01:00
styleName.indexOf('.') === 0 &&
2019-06-25 22:20:24 +02:00
parentKey &&
2020-01-28 20:07:21 +01:00
parentKey.indexOf('.') === 0
2019-06-25 22:20:24 +02:00
) {
if (grandparent) {
if (!grandparent[styleName]) {
grandparent[styleName] = {};
} else {
grandparent[styleName][parentKey] = style;
}
}
}
2020-01-28 20:07:21 +01:00
if (
style &&
typeof style === 'object' &&
styleName !== 'fontVariant' &&
styleName !== 'transform'
) {
2019-06-25 22:20:24 +02:00
cssifyTheme(parent, style, styleName);
}
});
};
cssifyTheme(null, theme, null);
return theme;
};