-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CSS Extraction & Disable Style Injection (#2655)
Co-authored-by: origami-z <[email protected]>
- Loading branch information
Showing
41 changed files
with
7,991 additions
and
186 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"@salt-ds/core": minor | ||
"@salt-ds/icons": minor | ||
"@salt-ds/lab": minor | ||
"@salt-ds/styles": minor | ||
--- | ||
|
||
Supports turning off style injection via `SaltProvider`. | ||
|
||
``` | ||
<SaltProvider enableStyleInjection={false} /** other props*/ > | ||
``` |
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,42 @@ | ||
import { useEffect } from "react"; | ||
import { QAContainer, QAContainerProps } from "./QAContainer"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// eslint-disable-next-line import/no-unresolved | ||
import coreCss from "../css/salt-core.css?inline"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// eslint-disable-next-line import/no-unresolved | ||
import iconCss from "../../packages/icons/src/icon/Icon.css?inline"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// eslint-disable-next-line import/no-unresolved | ||
import labCss from "../css/salt-lab.css?inline"; | ||
|
||
export const useDynamicStyleSheet = (styleSheet: string, id: string): void => { | ||
useEffect(() => { | ||
const styleElement = document.createElement("style"); | ||
styleElement.id = id; | ||
styleElement.innerHTML = styleSheet; | ||
document.head.append(styleElement); | ||
return () => styleElement.remove(); | ||
}, [styleSheet, id]); | ||
}; | ||
|
||
export interface QAContainerNoStyleInjectionProps extends QAContainerProps { | ||
enableStyleInjection: false; | ||
} | ||
|
||
export const QAContainerNoStyleInjection = ( | ||
props: QAContainerNoStyleInjectionProps | ||
) => { | ||
// order is important! | ||
useDynamicStyleSheet(String(iconCss), "salt-icon-css"); | ||
useDynamicStyleSheet(String(coreCss), "salt-core-css"); | ||
useDynamicStyleSheet(String(labCss), "salt-lab-css"); | ||
|
||
return <QAContainer {...props} enableStyleInjection={false} />; | ||
}; |
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,3 +1,4 @@ | ||
export * from "./AllRenderer"; | ||
export * from "./BackgroundBlock"; | ||
export * from "./QAContainer"; | ||
export * from "./QAContainerNoStyleInjection"; |
Oops, something went wrong.
966c362
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
saltdesignsystem – ./
saltdesignsystem-fed-team.vercel.app
saltdesignsystem-git-main-fed-team.vercel.app
saltdesignsystem.vercel.app
next.saltdesignsystem.com
www.saltdesignsystem.com