-
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.
- Loading branch information
Showing
9 changed files
with
189 additions
and
17 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -1,10 +1,7 @@ | ||
import { position, positionShort } from './position' | ||
import { createPos4Props } from './position' | ||
import type { PropsAtomicMap } from '../types' | ||
|
||
export const border: PropsAtomicMap[] = [ | ||
['border', ['border', 'b']], | ||
[/^border-(top|bottom|left|right)(?:-\w+)?$/, ([, p]) => { | ||
const index = position.indexOf(p) | ||
return [`border-${positionShort[index]}`, `b-${positionShort[index]}`] | ||
}], | ||
createPos4Props('border', 'border', 'b'), | ||
] |
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,8 @@ | ||
import type { StaticPropAtomicMap } from '../types' | ||
|
||
export const colors: StaticPropAtomicMap[] = [ | ||
['color', 'c'], | ||
['background', 'bg'], | ||
['background-color', 'bg'], | ||
['border-color', ['border', 'b']], | ||
] |
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,9 +1,11 @@ | ||
import { border } from './border' | ||
import { colors } from './color' | ||
import { margin } from './margin' | ||
import { positions } from './position' | ||
|
||
export const maps = [ | ||
border, | ||
positions, | ||
margin, | ||
colors, | ||
].flat(1) |
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,9 +1,22 @@ | ||
import type { PropsAtomicMap } from '../types' | ||
import type { AtomicComposed, DynamicPropAtomicMap, PropsAtomicMap, StaticPropAtomicMap } from '../types' | ||
|
||
export const position = ['top', 'bottom', 'left', 'right'] | ||
export const positionShort = ['t', 'b', 'l', 'r'] | ||
|
||
export const positions: PropsAtomicMap[] = position.map((p, i) => [ | ||
p, | ||
[p, positionShort[i]], | ||
]) | ||
export const positions: PropsAtomicMap[] = [ | ||
...position.map<StaticPropAtomicMap>((p, i) => [p, [p, positionShort[i]]]), | ||
createPos4Props('margin', 'margin', 'm'), | ||
createPos4Props('padding', 'padding', 'p'), | ||
] | ||
|
||
export function createPos4Props(prop: string, atom: string, shortAtom?: string): DynamicPropAtomicMap { | ||
return [ | ||
new RegExp(`^${prop}-(top|bottom|left|right)(?:-\\w+)?$`), | ||
([, p]) => { | ||
const index = position.indexOf(p) | ||
if (index > -1) { | ||
return [atom, shortAtom].filter(Boolean).map(s => `${s}-${positionShort[index]}`) as AtomicComposed | ||
} | ||
}, | ||
] | ||
} |
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