@neko-os/ui 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abstractions/BKTouchableOpacity.js +0 -0
- package/dist/abstractions/HiddenInput.js +1 -0
- package/dist/abstractions/HiddenInput.native.js +1 -0
- package/dist/abstractions/Icon.js +1 -1
- package/dist/abstractions/Icon.native.js +1 -1
- package/dist/abstractions/Icon.web.js +1 -1
- package/dist/abstractions/Switch.js +1 -0
- package/dist/abstractions/Switch.native.js +1 -0
- package/dist/abstractions/TouchableOpacity.js +1 -1
- package/dist/abstractions/TouchableOpacity.native.js +1 -0
- package/dist/abstractions/TouchableOpacity.web.js +1 -0
- package/dist/abstractions/windowWidth.js +1 -0
- package/dist/abstractions/windowWidth.native.js +1 -0
- package/dist/abstractions/windowWidth.web.js +1 -0
- package/dist/components/actions/Button.js +1 -0
- package/dist/components/actions/Link.js +1 -0
- package/dist/components/actions/index.js +1 -0
- package/dist/components/form/Form.js +1 -0
- package/dist/components/form/FormGroup.js +1 -0
- package/dist/components/form/FormItem.js +1 -0
- package/dist/components/form/FormList.js +1 -0
- package/dist/components/form/FormWrapperComponent.js +1 -0
- package/dist/{form → components/form}/index.js +1 -1
- package/dist/components/form/inputs/Checkbox.js +1 -0
- package/dist/components/form/inputs/Radio.js +1 -0
- package/dist/components/form/inputs/Switch.js +1 -0
- package/dist/components/form/inputs/index.js +1 -0
- package/dist/components/helpers/Responsive.js +1 -0
- package/dist/components/helpers/Separator.js +1 -0
- package/dist/components/helpers/index.js +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/presentation/ContentLabel.js +1 -0
- package/dist/components/presentation/Icon.js +1 -0
- package/dist/components/presentation/IconLabel.js +1 -0
- package/dist/components/presentation/Tag.js +1 -0
- package/dist/components/presentation/index.js +1 -0
- package/dist/components/structure/Card.js +1 -0
- package/dist/components/structure/View.js +1 -0
- package/dist/components/text/Text.js +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/responsive.js +1 -0
- package/dist/index.css +5 -0
- package/dist/index.js +1 -1
- package/dist/modifiers/background.js +1 -1
- package/dist/modifiers/border.js +1 -1
- package/dist/modifiers/colorConverter.js +1 -0
- package/dist/modifiers/default.js +1 -0
- package/dist/modifiers/display.js +1 -0
- package/dist/modifiers/flex.js +1 -1
- package/dist/modifiers/flexWrapper.js +1 -1
- package/dist/modifiers/fullColor.js +1 -0
- package/dist/modifiers/logger.js +1 -0
- package/dist/modifiers/margin.js +1 -1
- package/dist/modifiers/padding.js +1 -1
- package/dist/modifiers/position.js +1 -1
- package/dist/modifiers/shadow.js +1 -1
- package/dist/modifiers/size.js +1 -1
- package/dist/modifiers/sizeConverter.js +1 -0
- package/dist/modifiers/text.js +1 -1
- package/dist/modifiers/textConverter.js +1 -0
- package/dist/modifiers/themeComponent.js +1 -0
- package/dist/theme/ThemeHandler.js +1 -1
- package/dist/theme/default/base.js +1 -1
- package/dist/theme/default/cyberpunkTheme.js +1 -1
- package/dist/theme/default/darkTheme.js +1 -1
- package/dist/theme/default/deepWoodsTheme.js +1 -1
- package/dist/theme/default/forestTheme.js +1 -1
- package/dist/theme/default/hackerTheme.js +1 -0
- package/dist/theme/default/lightTheme.js +1 -1
- package/dist/theme/default/midnightTheme.js +1 -1
- package/dist/theme/default/msdosTheme.js +1 -0
- package/dist/theme/default/oceanTheme.js +1 -1
- package/dist/theme/default/pastelTheme.js +1 -1
- package/dist/theme/default/sunsetTheme.js +1 -1
- package/dist/theme/default/themes.js +1 -1
- package/dist/theme/helpers/colorScale.js +1 -0
- package/dist/theme/helpers/mergePreset.js +1 -0
- package/dist/theme/helpers/relatedScales.js +1 -0
- package/dist/theme/helpers/sizeScale.js +1 -1
- package/dist/theme/helpers/textScale.js +1 -0
- package/package.json +1 -1
- package/src/abstractions/BKTouchableOpacity.js +12 -0
- package/src/abstractions/HiddenInput.js +3 -0
- package/src/abstractions/HiddenInput.native.js +3 -0
- package/src/abstractions/Icon.js +23 -1
- package/src/abstractions/Icon.native.js +11 -2
- package/src/abstractions/Icon.web.js +11 -2
- package/src/abstractions/Switch.js +97 -0
- package/src/abstractions/Switch.native.js +12 -0
- package/src/abstractions/TouchableOpacity.js +3 -11
- package/src/abstractions/TouchableOpacity.native.js +3 -0
- package/src/abstractions/TouchableOpacity.web.js +3 -0
- package/src/abstractions/windowWidth.js +13 -0
- package/src/abstractions/windowWidth.native.js +6 -0
- package/src/abstractions/windowWidth.web.js +6 -0
- package/src/components/actions/Button.js +62 -0
- package/src/components/actions/Link.js +39 -0
- package/src/{actions → components/actions}/index.js +1 -0
- package/src/{form → components/form}/FormItem.js +2 -2
- package/src/{form → components/form}/FormList.js +2 -2
- package/src/{form → components/form}/index.js +1 -0
- package/src/components/form/inputs/Checkbox.js +42 -0
- package/src/components/form/inputs/Radio.js +42 -0
- package/src/components/form/inputs/Switch.js +44 -0
- package/src/components/form/inputs/index.js +3 -0
- package/src/components/helpers/Responsive.js +18 -0
- package/src/components/helpers/Separator.js +49 -0
- package/src/components/helpers/index.js +2 -0
- package/src/components/index.js +6 -0
- package/src/components/presentation/ContentLabel.js +25 -0
- package/src/components/presentation/Icon.js +20 -0
- package/src/components/presentation/IconLabel.js +29 -0
- package/src/components/presentation/Tag.js +72 -0
- package/src/{presentation → components/presentation}/index.js +1 -0
- package/src/components/structure/Card.js +42 -0
- package/src/components/structure/View.js +36 -0
- package/src/components/text/Text.js +28 -0
- package/src/helpers/index.js +2 -0
- package/src/helpers/responsive.js +54 -0
- package/src/index.css +5 -0
- package/src/index.js +2 -5
- package/src/modifiers/background.js +10 -7
- package/src/modifiers/border.js +10 -7
- package/src/modifiers/colorConverter.js +13 -0
- package/src/modifiers/default.js +9 -0
- package/src/modifiers/display.js +24 -0
- package/src/modifiers/flex.js +10 -7
- package/src/modifiers/flexWrapper.js +12 -9
- package/src/modifiers/{fullColor.js.js → fullColor.js} +8 -9
- package/src/modifiers/logger.js +6 -0
- package/src/modifiers/margin.js +10 -7
- package/src/modifiers/padding.js +10 -7
- package/src/modifiers/position.js +10 -7
- package/src/modifiers/shadow.js +10 -7
- package/src/modifiers/size.js +8 -5
- package/src/modifiers/sizeConverter.js +12 -0
- package/src/modifiers/text.js +14 -13
- package/src/modifiers/textConverter.js +12 -0
- package/src/modifiers/themeComponent.js +11 -0
- package/src/theme/ThemeHandler.js +31 -33
- package/src/theme/default/base.js +13 -1
- package/src/theme/default/cyberpunkTheme.js +1 -0
- package/src/theme/default/darkTheme.js +1 -0
- package/src/theme/default/deepWoodsTheme.js +1 -0
- package/src/theme/default/forestTheme.js +1 -0
- package/src/theme/default/hackerTheme.js +32 -0
- package/src/theme/default/lightTheme.js +1 -0
- package/src/theme/default/midnightTheme.js +1 -0
- package/src/theme/default/msdosTheme.js +40 -0
- package/src/theme/default/oceanTheme.js +1 -0
- package/src/theme/default/pastelTheme.js +1 -0
- package/src/theme/default/sunsetTheme.js +1 -0
- package/src/theme/default/themes.js +4 -0
- package/src/theme/helpers/colorScale.js +11 -0
- package/src/theme/helpers/mergePreset.js +7 -0
- package/src/theme/helpers/relatedScales.js +34 -0
- package/src/theme/helpers/sizeScale.js +12 -4
- package/src/theme/helpers/textScale.js +15 -0
- package/dist/actions/Button.js +0 -1
- package/dist/actions/index.js +0 -1
- package/dist/form/Form.js +0 -1
- package/dist/form/FormGroup.js +0 -1
- package/dist/form/FormItem.js +0 -1
- package/dist/form/FormList.js +0 -1
- package/dist/form/FormWrapperComponent.js +0 -1
- package/dist/modifiers/fullColor.js.js +0 -1
- package/dist/presentation/Icon.js +0 -1
- package/dist/presentation/Tag.js +0 -1
- package/dist/presentation/index.js +0 -1
- package/dist/structure/Card.js +0 -1
- package/dist/structure/View.js +0 -1
- package/dist/text/Text.js +0 -1
- package/dist/theme/default/base.native.js +0 -1
- package/dist/theme/default/base.web.js +0 -1
- package/src/actions/Button.js +0 -48
- package/src/presentation/Icon.js +0 -14
- package/src/presentation/Tag.js +0 -32
- package/src/structure/Card.js +0 -36
- package/src/structure/View.js +0 -34
- package/src/text/Text.js +0 -20
- package/src/theme/default/base.native.js +0 -58
- package/src/theme/default/base.web.js +0 -3
- /package/dist/{form → components/form}/FormWrapperComponent.native.js +0 -0
- /package/dist/{form → components/form}/useForm.js +0 -0
- /package/dist/{structure → components/structure}/index.js +0 -0
- /package/dist/{text → components/text}/index.js +0 -0
- /package/src/{form → components/form}/Form.js +0 -0
- /package/src/{form → components/form}/FormGroup.js +0 -0
- /package/src/{form → components/form}/FormWrapperComponent.js +0 -0
- /package/src/{form → components/form}/FormWrapperComponent.native.js +0 -0
- /package/src/{form → components/form}/useForm.js +0 -0
- /package/src/{structure → components/structure}/index.js +0 -0
- /package/src/{text → components/text}/index.js +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { ContentLabel } from './ContentLabel'
|
|
4
|
+
import { Icon } from './Icon'
|
|
5
|
+
import { useColorConverter } from '../../modifiers/colorConverter'
|
|
6
|
+
import { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
7
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
8
|
+
|
|
9
|
+
export function IconLabel(rootProps) {
|
|
10
|
+
const [{ sizeCode, color }, formattedProps] = pipe(
|
|
11
|
+
useColorConverter(),
|
|
12
|
+
useSizeConverter('icons', 'md'),
|
|
13
|
+
useThemeComponentModifier('IconLabel') //
|
|
14
|
+
)([{}, rootProps])
|
|
15
|
+
|
|
16
|
+
const { icon, iconProps, ...props } = formattedProps
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ContentLabel
|
|
20
|
+
className="neko-icon-label"
|
|
21
|
+
color={color}
|
|
22
|
+
size={sizeCode}
|
|
23
|
+
content={!!icon && <Icon name={icon} size={sizeCode} color={color} {...iconProps} />}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const IconText = IconLabel
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsView } from '../../abstractions/View'
|
|
4
|
+
import { IconLabel } from './IconLabel'
|
|
5
|
+
import { View } from '../structure/View'
|
|
6
|
+
import { moveScale } from '../../theme/helpers/sizeScale'
|
|
7
|
+
import { useBackgroundModifier } from '../../modifiers/background'
|
|
8
|
+
import { useBorderModifier } from '../../modifiers/border'
|
|
9
|
+
import { useColorConverter } from '../../modifiers/colorConverter'
|
|
10
|
+
import { useDefaultModifier } from '../../modifiers/default'
|
|
11
|
+
import { useFlexModifier } from '../../modifiers/flex'
|
|
12
|
+
import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
|
|
13
|
+
import { useFullColorModifier } from '../../modifiers/fullColor'
|
|
14
|
+
import { useMarginModifier } from '../../modifiers/margin'
|
|
15
|
+
import { usePaddingModifier } from '../../modifiers/padding'
|
|
16
|
+
import { usePositionModifier } from '../../modifiers/position'
|
|
17
|
+
import { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
18
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
19
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
20
|
+
|
|
21
|
+
const DEFAULT_PROPS = ([{ sizeCode }]) => {
|
|
22
|
+
const oneSizeDown = moveScale(sizeCode, -1)
|
|
23
|
+
const twoSizeDown = moveScale(sizeCode, -2)
|
|
24
|
+
const threeSizeDown = moveScale(sizeCode, -3)
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
paddingH: twoSizeDown,
|
|
28
|
+
padding: threeSizeDown,
|
|
29
|
+
outline: true,
|
|
30
|
+
br: threeSizeDown,
|
|
31
|
+
borderWidth: 1,
|
|
32
|
+
center: true,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function Tag(rootProps) {
|
|
37
|
+
const [{ fontColor, sizeCode }, formattedProps] = pipe(
|
|
38
|
+
useColorConverter('primary'),
|
|
39
|
+
useSizeConverter('elementHeights', 'md'),
|
|
40
|
+
useThemeComponentModifier('Tag'),
|
|
41
|
+
useDefaultModifier(DEFAULT_PROPS),
|
|
42
|
+
useFullColorModifier,
|
|
43
|
+
useSizeModifier,
|
|
44
|
+
usePositionModifier,
|
|
45
|
+
usePaddingModifier,
|
|
46
|
+
useMarginModifier,
|
|
47
|
+
useFlexModifier,
|
|
48
|
+
useFlexWrapperModifier,
|
|
49
|
+
useBackgroundModifier,
|
|
50
|
+
useBorderModifier
|
|
51
|
+
)([{}, rootProps])
|
|
52
|
+
|
|
53
|
+
const { label, icon, textProps, iconProps, gap, invert, ...props } = formattedProps
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<View className="neko-tag" row>
|
|
57
|
+
<AbsView className="neko-tag-inner" {...props}>
|
|
58
|
+
<IconLabel
|
|
59
|
+
center
|
|
60
|
+
color={fontColor}
|
|
61
|
+
size={moveScale(sizeCode, -1)}
|
|
62
|
+
label={label}
|
|
63
|
+
icon={icon}
|
|
64
|
+
gap={gap}
|
|
65
|
+
invert={invert}
|
|
66
|
+
textProps={{ strong: true, ...textProps }}
|
|
67
|
+
iconProps={iconProps}
|
|
68
|
+
/>
|
|
69
|
+
</AbsView>
|
|
70
|
+
</View>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsView } from '../../abstractions/View'
|
|
4
|
+
import { useBackgroundModifier } from '../../modifiers/background'
|
|
5
|
+
import { useBorderModifier } from '../../modifiers/border'
|
|
6
|
+
import { useDefaultModifier } from '../../modifiers/default'
|
|
7
|
+
import { useFlexModifier } from '../../modifiers/flex'
|
|
8
|
+
import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
|
|
9
|
+
import { useMarginModifier } from '../../modifiers/margin'
|
|
10
|
+
import { usePaddingModifier } from '../../modifiers/padding'
|
|
11
|
+
import { usePositionModifier } from '../../modifiers/position'
|
|
12
|
+
import { useShadowModifier } from '../../modifiers/shadow'
|
|
13
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
14
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
15
|
+
|
|
16
|
+
const DEFAULT_PROPS = {
|
|
17
|
+
padding: 'md', //
|
|
18
|
+
br: 'xlg',
|
|
19
|
+
bg: 'overlayBG',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function Card({ children, ...rootProps }) {
|
|
23
|
+
const [_, props] = pipe(
|
|
24
|
+
useThemeComponentModifier('Card'),
|
|
25
|
+
useDefaultModifier(DEFAULT_PROPS),
|
|
26
|
+
useSizeModifier, //
|
|
27
|
+
usePositionModifier,
|
|
28
|
+
usePaddingModifier,
|
|
29
|
+
useMarginModifier,
|
|
30
|
+
useFlexWrapperModifier,
|
|
31
|
+
useFlexModifier,
|
|
32
|
+
useBackgroundModifier,
|
|
33
|
+
useBorderModifier,
|
|
34
|
+
useShadowModifier
|
|
35
|
+
)([{}, rootProps])
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<AbsView className="neko-card" {...props}>
|
|
39
|
+
{children}
|
|
40
|
+
</AbsView>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsView } from '../../abstractions/View'
|
|
4
|
+
import { useBackgroundModifier } from '../../modifiers/background'
|
|
5
|
+
import { useBorderModifier } from '../../modifiers/border'
|
|
6
|
+
import { useDisplayModifier } from '../../modifiers/display'
|
|
7
|
+
import { useFlexModifier } from '../../modifiers/flex'
|
|
8
|
+
import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
|
|
9
|
+
import { useMarginModifier } from '../../modifiers/margin'
|
|
10
|
+
import { usePaddingModifier } from '../../modifiers/padding'
|
|
11
|
+
import { usePositionModifier } from '../../modifiers/position'
|
|
12
|
+
import { useShadowModifier } from '../../modifiers/shadow'
|
|
13
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
14
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
15
|
+
|
|
16
|
+
export function View({ children, ...rootProps }) {
|
|
17
|
+
const [_, props] = pipe(
|
|
18
|
+
useThemeComponentModifier('View'),
|
|
19
|
+
useDisplayModifier, //
|
|
20
|
+
useSizeModifier, //
|
|
21
|
+
usePositionModifier,
|
|
22
|
+
usePaddingModifier,
|
|
23
|
+
useMarginModifier,
|
|
24
|
+
useFlexWrapperModifier,
|
|
25
|
+
useFlexModifier,
|
|
26
|
+
useBackgroundModifier,
|
|
27
|
+
useBorderModifier,
|
|
28
|
+
useShadowModifier
|
|
29
|
+
)([{}, rootProps])
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<AbsView className="neko-view" {...props}>
|
|
33
|
+
{children}
|
|
34
|
+
</AbsView>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsText } from '../../abstractions/Text'
|
|
4
|
+
import { useColorConverter } from '../../modifiers/colorConverter'
|
|
5
|
+
import { useFlexModifier } from '../../modifiers/flex'
|
|
6
|
+
import { useMarginModifier } from '../../modifiers/margin'
|
|
7
|
+
import { usePaddingModifier } from '../../modifiers/padding'
|
|
8
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
9
|
+
import { useTextConverter } from '../../modifiers/textConverter'
|
|
10
|
+
import { useTextModifier } from '../../modifiers/text'
|
|
11
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
12
|
+
|
|
13
|
+
export function Text({ children, label, ...rootProps }) {
|
|
14
|
+
const [_, props] = pipe(
|
|
15
|
+
useColorConverter('text'),
|
|
16
|
+
useTextConverter('p'),
|
|
17
|
+
useThemeComponentModifier('Text'),
|
|
18
|
+
useSizeModifier, //
|
|
19
|
+
usePaddingModifier,
|
|
20
|
+
useMarginModifier,
|
|
21
|
+
useFlexModifier,
|
|
22
|
+
useTextModifier
|
|
23
|
+
)([{}, rootProps])
|
|
24
|
+
|
|
25
|
+
return <AbsText {...props}>{children || label}</AbsText>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const Title = Text
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { is } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { useBreakpoints } from '../theme/ThemeHandler'
|
|
4
|
+
import { useWindowWidth } from '../abstractions/windowWidth'
|
|
5
|
+
|
|
6
|
+
export function useResponsiveScreen() {
|
|
7
|
+
const breakpoints = useBreakpoints()
|
|
8
|
+
const width = useWindowWidth()
|
|
9
|
+
if (!breakpoints?.length) return false
|
|
10
|
+
|
|
11
|
+
// Find which breakpoint range we're in
|
|
12
|
+
for (let i = 0; i < breakpoints.length; i++) {
|
|
13
|
+
if (width < breakpoints[i].value) {
|
|
14
|
+
return breakpoints[i].name
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// If width is greater than all breakpoints, return the last one
|
|
19
|
+
return breakpoints[breakpoints.length - 1]?.name
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function useResponsiveValue(value) {
|
|
23
|
+
const breakpoints = useBreakpoints()
|
|
24
|
+
const width = useWindowWidth()
|
|
25
|
+
const screen = useResponsiveScreen()
|
|
26
|
+
|
|
27
|
+
if (!is(Object, value)) return value
|
|
28
|
+
|
|
29
|
+
if (value[screen]) return value[screen]
|
|
30
|
+
|
|
31
|
+
const keys = Object.keys(value)
|
|
32
|
+
for (let k of keys) {
|
|
33
|
+
const match = k.match(/^(\w+)([du])$/)
|
|
34
|
+
if (!match) continue
|
|
35
|
+
|
|
36
|
+
const bpName = match[1]
|
|
37
|
+
const mode = match[2]
|
|
38
|
+
|
|
39
|
+
const bpIndex = breakpoints.findIndex((b) => b.name === bpName)
|
|
40
|
+
if (bpIndex === -1) continue
|
|
41
|
+
|
|
42
|
+
// For "up", use the lower boundary of the range (previous breakpoint value)
|
|
43
|
+
// For "down", use the upper boundary of the range (current breakpoint value)
|
|
44
|
+
if (mode === 'u') {
|
|
45
|
+
const lowerBound = bpIndex > 0 ? breakpoints[bpIndex - 1].value : 0
|
|
46
|
+
if (width >= lowerBound) return value[k]
|
|
47
|
+
}
|
|
48
|
+
if (mode === 'd') {
|
|
49
|
+
if (width < breakpoints[bpIndex].value) return value[k]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return value?.df
|
|
54
|
+
}
|
package/src/index.css
CHANGED
package/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clearProps } from './_helpers'
|
|
2
2
|
import { useGetColor } from '../theme/ThemeHandler'
|
|
3
3
|
|
|
4
|
-
export function useBackgroundModifier(props) {
|
|
4
|
+
export function useBackgroundModifier([values, props]) {
|
|
5
5
|
const getColor = useGetColor()
|
|
6
6
|
let { bg, background, backgroundColor, ...restProps } = props
|
|
7
7
|
|
|
@@ -9,11 +9,14 @@ export function useBackgroundModifier(props) {
|
|
|
9
9
|
|
|
10
10
|
const style = clearProps({ backgroundColor })
|
|
11
11
|
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
...
|
|
16
|
-
|
|
12
|
+
return [
|
|
13
|
+
values,
|
|
14
|
+
{
|
|
15
|
+
...restProps,
|
|
16
|
+
style: {
|
|
17
|
+
...props.style,
|
|
18
|
+
...style,
|
|
19
|
+
},
|
|
17
20
|
},
|
|
18
|
-
|
|
21
|
+
]
|
|
19
22
|
}
|
package/src/modifiers/border.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clearProps } from './_helpers'
|
|
2
2
|
import { useGetColor, useGetRadius } from '../theme/ThemeHandler'
|
|
3
3
|
|
|
4
|
-
export function useBorderModifier(props) {
|
|
4
|
+
export function useBorderModifier([values, props]) {
|
|
5
5
|
const getRadius = useGetRadius()
|
|
6
6
|
const getColor = useGetColor()
|
|
7
7
|
let {
|
|
@@ -43,11 +43,14 @@ export function useBorderModifier(props) {
|
|
|
43
43
|
borderWidth,
|
|
44
44
|
})
|
|
45
45
|
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
...
|
|
50
|
-
|
|
46
|
+
return [
|
|
47
|
+
values,
|
|
48
|
+
{
|
|
49
|
+
...restProps,
|
|
50
|
+
style: {
|
|
51
|
+
...props.style,
|
|
52
|
+
...style,
|
|
53
|
+
},
|
|
51
54
|
},
|
|
52
|
-
|
|
55
|
+
]
|
|
53
56
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getColorFromProps } from '../theme/helpers/colorScale'
|
|
2
|
+
import { useGetColor } from '../theme/ThemeHandler'
|
|
3
|
+
|
|
4
|
+
export function useColorConverter(defaultValue) {
|
|
5
|
+
const getColor = useGetColor()
|
|
6
|
+
|
|
7
|
+
return ([values, props]) => {
|
|
8
|
+
const [colorCode, formattedProps] = getColorFromProps(props, defaultValue)
|
|
9
|
+
const color = getColor(colorCode)
|
|
10
|
+
|
|
11
|
+
return [{ ...values, color, colorCode }, formattedProps]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { mergeDeepRight, is } from 'ramda'
|
|
2
|
+
|
|
3
|
+
export function useDefaultModifier(defaultPropsOrFunc) {
|
|
4
|
+
return ([values, props]) => {
|
|
5
|
+
const defaultProps =
|
|
6
|
+
(is(Function, defaultPropsOrFunc) ? defaultPropsOrFunc([values, props]) : defaultPropsOrFunc) || {}
|
|
7
|
+
return [values, mergeDeepRight(defaultProps, props)]
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { clearProps } from './_helpers'
|
|
2
|
+
|
|
3
|
+
export function useDisplayModifier([values, props]) {
|
|
4
|
+
let { cursor, opacity, disabled, hidden, display, ...restProps } = props
|
|
5
|
+
|
|
6
|
+
if (!!hidden) display = 'hidden'
|
|
7
|
+
if (!!disabled) {
|
|
8
|
+
opacity = opacity || 0.4
|
|
9
|
+
cursor = 'not-allowed'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const style = clearProps({ display, opacity, cursor })
|
|
13
|
+
|
|
14
|
+
return [
|
|
15
|
+
values,
|
|
16
|
+
{
|
|
17
|
+
...restProps,
|
|
18
|
+
style: {
|
|
19
|
+
...props.style,
|
|
20
|
+
...style,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
]
|
|
24
|
+
}
|
package/src/modifiers/flex.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { clearProps } from './_helpers'
|
|
2
2
|
|
|
3
|
-
export function useFlexModifier(props) {
|
|
3
|
+
export function useFlexModifier([values, props]) {
|
|
4
4
|
let { flex, ...restProps } = props
|
|
5
5
|
|
|
6
6
|
if (flex === true) flex = 1
|
|
7
7
|
|
|
8
8
|
const style = clearProps({ flex })
|
|
9
9
|
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
...
|
|
14
|
-
|
|
10
|
+
return [
|
|
11
|
+
values,
|
|
12
|
+
{
|
|
13
|
+
...restProps,
|
|
14
|
+
style: {
|
|
15
|
+
...props.style,
|
|
16
|
+
...style,
|
|
17
|
+
},
|
|
15
18
|
},
|
|
16
|
-
|
|
19
|
+
]
|
|
17
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clearProps } from './_helpers'
|
|
2
2
|
import { useGetSpace } from '../theme/ThemeHandler'
|
|
3
3
|
|
|
4
|
-
export function useFlexWrapperModifier(props) {
|
|
4
|
+
export function useFlexWrapperModifier([values, props]) {
|
|
5
5
|
const getSpace = useGetSpace()
|
|
6
6
|
let { justify, align, center, centerV, centerH, toRight, toBottom, direction, row, wrap, gap, ...restProps } = props
|
|
7
7
|
|
|
@@ -15,9 +15,9 @@ export function useFlexWrapperModifier(props) {
|
|
|
15
15
|
justifyContent = 'center'
|
|
16
16
|
alignItems = 'center'
|
|
17
17
|
} else {
|
|
18
|
-
if (
|
|
18
|
+
if (centerH) justifyContent = 'center'
|
|
19
19
|
if (toBottom) justifyContent = 'flex-end'
|
|
20
|
-
if (
|
|
20
|
+
if (centerV) alignItems = 'center'
|
|
21
21
|
if (toRight) alignItems = 'flex-end'
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -33,11 +33,14 @@ export function useFlexWrapperModifier(props) {
|
|
|
33
33
|
gap,
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
...
|
|
40
|
-
|
|
36
|
+
return [
|
|
37
|
+
values,
|
|
38
|
+
{
|
|
39
|
+
...restProps,
|
|
40
|
+
style: {
|
|
41
|
+
...props.style,
|
|
42
|
+
...style,
|
|
43
|
+
},
|
|
41
44
|
},
|
|
42
|
-
|
|
45
|
+
]
|
|
43
46
|
}
|
|
@@ -2,27 +2,26 @@ import tinycolor from 'tinycolor2'
|
|
|
2
2
|
|
|
3
3
|
import { useGetColor } from '../theme/ThemeHandler'
|
|
4
4
|
|
|
5
|
-
export function useFullColorModifier(props) {
|
|
5
|
+
export function useFullColorModifier([{ color, ...values }, { outline, ...props }]) {
|
|
6
6
|
const getColor = useGetColor()
|
|
7
|
-
let { color, outline, ...restProps } = props
|
|
8
7
|
|
|
9
8
|
let bg = color
|
|
10
9
|
const bgObj = tinycolor(getColor(bg))
|
|
11
10
|
let borderColor = color
|
|
12
|
-
let
|
|
13
|
-
let
|
|
11
|
+
let fontColor = 'text'
|
|
12
|
+
let fontColorObj = tinycolor(getColor('text'))
|
|
14
13
|
|
|
15
14
|
if (!!outline) {
|
|
16
15
|
bg = 'transparent'
|
|
17
|
-
|
|
18
|
-
} else if (bgObj.isDark() ===
|
|
19
|
-
|
|
16
|
+
fontColor = color
|
|
17
|
+
} else if (bgObj.isDark() === fontColorObj.isDark()) {
|
|
18
|
+
fontColor = 'overlayBG'
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
return [
|
|
23
|
-
|
|
22
|
+
{ ...values, fontColor },
|
|
24
23
|
{
|
|
25
|
-
...
|
|
24
|
+
...props,
|
|
26
25
|
bg,
|
|
27
26
|
borderColor,
|
|
28
27
|
},
|
package/src/modifiers/margin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clearProps } from './_helpers'
|
|
2
2
|
import { useGetSpace } from '../theme/ThemeHandler'
|
|
3
3
|
|
|
4
|
-
export function useMarginModifier(props) {
|
|
4
|
+
export function useMarginModifier([values, props]) {
|
|
5
5
|
const getSpace = useGetSpace()
|
|
6
6
|
const { marginT, marginB, marginL, marginR, marginV, marginH, margin, ...restProps } = props
|
|
7
7
|
|
|
@@ -12,11 +12,14 @@ export function useMarginModifier(props) {
|
|
|
12
12
|
|
|
13
13
|
const style = clearProps({ marginTop, marginBottom, marginRight, marginLeft })
|
|
14
14
|
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
...
|
|
19
|
-
|
|
15
|
+
return [
|
|
16
|
+
values,
|
|
17
|
+
{
|
|
18
|
+
...restProps,
|
|
19
|
+
style: {
|
|
20
|
+
...props.style,
|
|
21
|
+
...style,
|
|
22
|
+
},
|
|
20
23
|
},
|
|
21
|
-
|
|
24
|
+
]
|
|
22
25
|
}
|
package/src/modifiers/padding.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clearProps } from './_helpers'
|
|
2
2
|
import { useGetSpace } from '../theme/ThemeHandler'
|
|
3
3
|
|
|
4
|
-
export function usePaddingModifier(props) {
|
|
4
|
+
export function usePaddingModifier([values, props]) {
|
|
5
5
|
const getSpace = useGetSpace()
|
|
6
6
|
const { paddingT, paddingB, paddingL, paddingR, paddingV, paddingH, padding, ...restProps } = props
|
|
7
7
|
|
|
@@ -12,11 +12,14 @@ export function usePaddingModifier(props) {
|
|
|
12
12
|
|
|
13
13
|
const style = clearProps({ paddingTop, paddingBottom, paddingRight, paddingLeft })
|
|
14
14
|
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
...
|
|
19
|
-
|
|
15
|
+
return [
|
|
16
|
+
values,
|
|
17
|
+
{
|
|
18
|
+
...restProps,
|
|
19
|
+
style: {
|
|
20
|
+
...props.style,
|
|
21
|
+
...style,
|
|
22
|
+
},
|
|
20
23
|
},
|
|
21
|
-
|
|
24
|
+
]
|
|
22
25
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { clearProps } from './_helpers'
|
|
2
2
|
|
|
3
|
-
export function usePositionModifier(props) {
|
|
3
|
+
export function usePositionModifier([values, props]) {
|
|
4
4
|
let { position, absolute, relative, top, bottom, left, right, ...restProps } = props
|
|
5
5
|
|
|
6
6
|
if (absolute) position = 'absolute'
|
|
@@ -8,11 +8,14 @@ export function usePositionModifier(props) {
|
|
|
8
8
|
|
|
9
9
|
const style = clearProps({ position, top, bottom, left, right })
|
|
10
10
|
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
...
|
|
15
|
-
|
|
11
|
+
return [
|
|
12
|
+
values,
|
|
13
|
+
{
|
|
14
|
+
...restProps,
|
|
15
|
+
style: {
|
|
16
|
+
...props.style,
|
|
17
|
+
...style,
|
|
18
|
+
},
|
|
16
19
|
},
|
|
17
|
-
|
|
20
|
+
]
|
|
18
21
|
}
|
package/src/modifiers/shadow.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clearProps } from './_helpers'
|
|
2
2
|
import { useGetColor } from '../theme/ThemeHandler'
|
|
3
3
|
|
|
4
|
-
export function useShadowModifier(props) {
|
|
4
|
+
export function useShadowModifier([values, props]) {
|
|
5
5
|
const getColor = useGetColor()
|
|
6
6
|
let { shadow, ...restProps } = props
|
|
7
7
|
|
|
@@ -22,11 +22,14 @@ export function useShadowModifier(props) {
|
|
|
22
22
|
|
|
23
23
|
const style = clearProps({ boxShadow, shadowRadius, shadowOffset, shadowOpacity, shadowColor, elevation })
|
|
24
24
|
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
...
|
|
29
|
-
|
|
25
|
+
return [
|
|
26
|
+
values,
|
|
27
|
+
{
|
|
28
|
+
...restProps,
|
|
29
|
+
style: {
|
|
30
|
+
...props.style,
|
|
31
|
+
...style,
|
|
32
|
+
},
|
|
30
33
|
},
|
|
31
|
-
|
|
34
|
+
]
|
|
32
35
|
}
|
package/src/modifiers/size.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clearProps } from './_helpers'
|
|
2
2
|
import { useGetElementHeight } from '../theme/ThemeHandler'
|
|
3
3
|
|
|
4
|
-
export function useSizeModifier(props) {
|
|
4
|
+
export function useSizeModifier([values, props]) {
|
|
5
5
|
const getHeight = useGetElementHeight()
|
|
6
6
|
let {
|
|
7
7
|
width,
|
|
@@ -39,8 +39,11 @@ export function useSizeModifier(props) {
|
|
|
39
39
|
|
|
40
40
|
const style = clearProps({ height, width, minHeight, minHeight, maxHeight, maxWidth, aspectRatio })
|
|
41
41
|
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
return [
|
|
43
|
+
values,
|
|
44
|
+
{
|
|
45
|
+
...restProps,
|
|
46
|
+
style: { ...props.style, ...style },
|
|
47
|
+
},
|
|
48
|
+
]
|
|
46
49
|
}
|