-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from ineshbose/issue/116-bootstrapping_styles
Bootstrapped styles
- Loading branch information
Showing
23 changed files
with
400 additions
and
318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { DisplayType } from '../../types/styles'; | ||
|
||
const DISPLAYS: DisplayType['options'][] = ['None', 'Flex']; | ||
|
||
const displayStyles = <DisplayType['styles']>{}; | ||
|
||
DISPLAYS.forEach((display) => { | ||
displayStyles[`display${display}`] = { | ||
display: <Lowercase<typeof display>>display.toLowerCase(), | ||
}; | ||
}); | ||
|
||
export default displayStyles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { | ||
AlignType, | ||
AlignTypes, | ||
FlexDirectionType, | ||
FlexStyles, | ||
JustifyContentType, | ||
StyleNumValues, | ||
} from '../../types/styles'; | ||
|
||
const flexStyles = <FlexStyles>{}; | ||
|
||
const NUMS: StyleNumValues[] = [0, 1, 2, 3, 4, 5]; | ||
|
||
NUMS.forEach((num) => { | ||
flexStyles[`flex${num}`] = { | ||
flex: num, | ||
}; | ||
}); | ||
|
||
const DIRECTIONS: FlexDirectionType['options'][] = [ | ||
'Row', | ||
'Column', | ||
'Column-reverse', | ||
'Row-reverse', | ||
]; | ||
|
||
DIRECTIONS.forEach((direction) => { | ||
flexStyles[`flexDirection${direction}`] = { | ||
flexDirection: <Lowercase<typeof direction>>direction.toLowerCase(), | ||
}; | ||
}); | ||
|
||
type OptionMap = { [K in AlignTypes]: AlignType[Lowercase<K>]['options'][] }; | ||
|
||
const ALIGNMENTS: OptionMap = { | ||
Content: [ | ||
'Center', | ||
'Flex-end', | ||
'Flex-start', | ||
'Space-around', | ||
'Space-between', | ||
'Stretch', | ||
], | ||
Items: ['Baseline', 'Center', 'Flex-end', 'Flex-start', 'Stretch'], | ||
Self: ['Auto', 'Baseline', 'Center', 'Flex-end', 'Flex-start', 'Stretch'], | ||
}; | ||
|
||
const alignTypes: AlignTypes[] = ['Content', 'Items', 'Self']; | ||
|
||
alignTypes.forEach((alignType) => | ||
ALIGNMENTS[alignType].forEach((alignment) => { | ||
// @ts-ignore | ||
flexStyles[`align${alignType}${alignment}`] = { | ||
[`align${alignType}`]: <Lowercase<typeof alignment>>( | ||
alignment.toLowerCase() | ||
), | ||
}; | ||
}) | ||
); | ||
|
||
const justifyTypes: JustifyContentType['options'][] = [ | ||
'Center', | ||
'Flex-end', | ||
'Flex-start', | ||
'Space-around', | ||
'Space-between', | ||
'Space-evenly', | ||
]; | ||
|
||
justifyTypes.forEach((justifyType) => { | ||
flexStyles[`justifyContent${justifyType}`] = { | ||
justifyContent: <Lowercase<typeof justifyType>>justifyType.toLowerCase(), | ||
}; | ||
}); | ||
|
||
export default flexStyles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { StyleSheet } from 'react-native'; | ||
import { GlobalStyleSheet } from '../../types/styles'; | ||
import displayStyles from './display'; | ||
import flexStyles from './flex'; | ||
import spacingStyles from './spacing'; | ||
|
||
const PROVIDED_STYLES = <GlobalStyleSheet>{ | ||
...spacingStyles, | ||
...displayStyles, | ||
...flexStyles, | ||
}; | ||
|
||
export default function createStyle< | ||
T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any> | ||
>(styles: T | StyleSheet.NamedStyles<T>) { | ||
return StyleSheet.create({ ...PROVIDED_STYLES, ...styles }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
SpacingDirections, | ||
SpacingStyles, | ||
SpacingTypes, | ||
StyleNumValues, | ||
} from '../../types/styles'; | ||
|
||
const NUMS: StyleNumValues[] = [0, 1, 2, 3, 4, 5]; | ||
|
||
const SPACINGS: SpacingTypes[] = ['margin', 'padding']; | ||
|
||
const DIRECTIONS: SpacingDirections[] = [ | ||
'', | ||
'Horizontal', | ||
'Vertical', | ||
'Top', | ||
'Bottom', | ||
'Left', | ||
'Right', | ||
]; | ||
|
||
const spacingStyles = <SpacingStyles>{}; | ||
|
||
NUMS.forEach((num) => | ||
SPACINGS.forEach((spacing) => | ||
DIRECTIONS.forEach((direction) => { | ||
spacingStyles[`${spacing}${direction}${num}`] = { | ||
[`${spacing}${direction}`]: num * 16, | ||
}; | ||
}) | ||
) | ||
); | ||
|
||
export default spacingStyles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.