-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/animation-style-props
- Loading branch information
Showing
60 changed files
with
1,650 additions
and
657 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,25 @@ | ||
import type * as CSS from 'csstype'; | ||
import { ifProp } from '../styleHelpers/styleProp'; | ||
import { Box, type BoxProps } from './Box'; | ||
import styled from '@emotion/styled'; | ||
import { flexContainer, FlexContainerProps } from './interpolations/flex'; | ||
|
||
export type FlexProps = BoxProps & { | ||
center?: boolean; | ||
equal?: boolean; | ||
end?: boolean; | ||
start?: boolean; | ||
between?: boolean; | ||
stretch?: boolean; | ||
direction?: CSS.Property.FlexDirection; | ||
}; | ||
|
||
const justifyContent = (where: CSS.Property.JustifyContent) => `justify-content: ${where};`; | ||
export type FlexProps = BoxProps & | ||
FlexContainerProps & { | ||
center?: boolean; | ||
equal?: boolean; | ||
end?: boolean; | ||
start?: boolean; | ||
between?: boolean; | ||
stretch?: boolean; | ||
}; | ||
|
||
export const Flex = styled(Box)<FlexProps>` | ||
display: flex; | ||
${flexContainer} | ||
${ifProp('center', 'justify-content: center; align-items: center;')} | ||
${ifProp('equal', '> * { flex-basis: 100%; flex-grow: 1; flex-shrink: 1; }')} | ||
${ifProp('between', justifyContent('space-between'))} | ||
${ifProp('end', justifyContent('flex-end'))} | ||
${ifProp('start', justifyContent('flex-start'))} | ||
${ifProp('stretch', 'align-items: stretch;')} | ||
${ifProp('direction', (_, value) => `flex-direction: ${value};`)} | ||
${ifProp('between', flexContainer.justifyContent('space-between'))} | ||
${ifProp('end', flexContainer.justifyContent('flex-end'))} | ||
${ifProp('start', flexContainer.justifyContent('flex-start'))} | ||
`; |
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,49 @@ | ||
import { defaultTheme } from '../../theme'; | ||
import { PabloThemeableProps } from '../../theme/types'; | ||
import { color } from './color'; | ||
|
||
let props: PabloThemeableProps = { | ||
theme: defaultTheme, | ||
} as any; | ||
|
||
beforeEach(() => { | ||
props = { | ||
theme: defaultTheme, | ||
} as any; | ||
}); | ||
|
||
test('bg color', () => { | ||
expect(color({ ...props, bgColor: 'brand.main' })).toEqual({ | ||
backgroundColor: 'var(--pbl-theme-colors-brand-main)', | ||
}); | ||
}); | ||
|
||
test('text color', () => { | ||
expect(color({ ...props, textColor: 'brand.main' })).toEqual({ | ||
color: 'var(--pbl-theme-colors-brand-main)', | ||
}); | ||
}); | ||
|
||
test('opacity', () => { | ||
expect(color({ ...props, opacity: 0.5 })).toEqual({ | ||
opacity: 0.5, | ||
}); | ||
expect(color({ ...props, opacity: '0.4' })).toEqual({ | ||
opacity: '0.4', | ||
}); | ||
}); | ||
|
||
test('styled interpolation functions', () => { | ||
expect(color.bgColor('brand.main')(props)).toEqual({ | ||
backgroundColor: 'var(--pbl-theme-colors-brand-main)', | ||
}); | ||
expect(color.textColor('brand.main')(props)).toEqual({ | ||
color: 'var(--pbl-theme-colors-brand-main)', | ||
}); | ||
expect(color.opacity(0.5)(props)).toEqual({ | ||
opacity: 0.5, | ||
}); | ||
expect(color.opacity('0.4')(props)).toEqual({ | ||
opacity: '0.4', | ||
}); | ||
}); |
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,25 @@ | ||
import { colorTransform, ResponsiveValue, system } from '../system'; | ||
import { CssColor, KeyMap } from '../../types'; | ||
import { Colors } from '../../theme/colors'; | ||
|
||
export interface ColorProps { | ||
bgColor?: ResponsiveValue<KeyMap<Colors> | CssColor>; | ||
textColor?: ResponsiveValue<KeyMap<Colors> | CssColor>; | ||
opacity?: ResponsiveValue<number>; | ||
} | ||
|
||
export const color = system([ | ||
{ | ||
properties: ['color'], | ||
fromProps: ['textColor'], | ||
transform: colorTransform, | ||
}, | ||
{ | ||
properties: ['backgroundColor'], | ||
fromProps: ['bgColor'], | ||
transform: colorTransform, | ||
}, | ||
{ | ||
properties: ['opacity'], | ||
}, | ||
]); |
Oops, something went wrong.