-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(framework): styles and staticAreaStyles may now be nested arrays (…
- Loading branch information
1 parent
bb624ae
commit bb87e65
Showing
10 changed files
with
26 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
import { getCustomCSS } from "./CustomStyle.js"; | ||
import getStylesString from "./getStylesString.js"; | ||
|
||
const getEffectiveStyle = ElementClass => { | ||
const tag = ElementClass.getMetadata().getTag(); | ||
const customStyle = getCustomCSS(tag) || ""; | ||
let componentStyles = ElementClass.styles; | ||
|
||
if (Array.isArray(componentStyles)) { | ||
componentStyles = componentStyles.join(" "); | ||
} | ||
return `${componentStyles} ${customStyle}`; | ||
const builtInStyles = getStylesString(ElementClass.styles); | ||
return `${builtInStyles} ${customStyle}`; | ||
}; | ||
|
||
|
||
export default getEffectiveStyle; |
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 @@ | ||
const getStylesString = styles => { | ||
if (Array.isArray(styles)) { | ||
return flatten(styles).join(" "); | ||
} | ||
|
||
return styles; | ||
}; | ||
|
||
const flatten = arr => { | ||
return arr.reduce((acc, val) => acc.concat(Array.isArray(val) ? flatten(val) : val), []); | ||
}; | ||
|
||
export default getStylesString; |
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