-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plasma-new-hope): resolve circular dependency
- Loading branch information
1 parent
6ad8287
commit 40612bf
Showing
5 changed files
with
39 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { ComponentConfig, HTMLAnyAttributes } from './types'; | ||
|
||
export const getStaticVariants = (config: ComponentConfig) => { | ||
if (!config.variations) { | ||
return []; | ||
} | ||
const res = []; | ||
const { variations } = config; | ||
|
||
// eslint-disable-next-line guard-for-in | ||
for (const key in variations) { | ||
const { css } = variations[key]; | ||
css && res.push(css); | ||
} | ||
|
||
return res; | ||
}; | ||
|
||
export const getDynamicVariants = (config: ComponentConfig) => { | ||
return (props: HTMLAnyAttributes) => { | ||
const res = []; | ||
|
||
// eslint-disable-next-line guard-for-in | ||
for (const key in config.variations) { | ||
if (key in props) { | ||
const variant = config.variations[key]; | ||
|
||
const css = variant[props[key]]; | ||
// no css for { modifier: true } | ||
css && Array.isArray(css) ? res.push(...css) : res.push(css); | ||
} | ||
} | ||
|
||
return res; | ||
}; | ||
}; |