-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docs): icon fonts switching, unloading theme variables bug (#3853)
* feat(docs): storybook font changing (fiori/horizon) * fix(docs): unloading theme variables fix * fix(docs): icon fonts switching in prod
- Loading branch information
1 parent
1f38481
commit c760c77
Showing
7 changed files
with
94 additions
and
101 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@import "../../src/fonts/sap_fonts"; | ||
|
||
body { | ||
font-family: '72', 'Open Sans', sans-serif; | ||
|
This file was deleted.
Oops, something went wrong.
33 changes: 15 additions & 18 deletions
33
.storybook/custom/styleChangers/dev/themeVariablesManager.js
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
36 changes: 36 additions & 0 deletions
36
.storybook/custom/styleChangers/utils/inlineStyleLazyLoader.js
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 @@ | ||
const uniqueIdentifier = "id"; | ||
let uniqueId = 0; | ||
|
||
function createStyleTag(content) { | ||
let style = document.createElement('style'); | ||
style.textContent = content; | ||
style.setAttribute("id", `style-${uniqueId++}`); | ||
return style; | ||
} | ||
|
||
function generateUseStyleTagFn(styleTag) { | ||
return () => { | ||
const uniqueValue = styleTag.getAttribute(uniqueIdentifier); | ||
const tagName = styleTag.tagName; | ||
|
||
// If such element with such unique attribute value already loaded on the page, no need to duplicate it once again. | ||
if (document.querySelector(`${tagName}[${uniqueIdentifier}="${uniqueValue}"]`) !== null) { | ||
return; | ||
} | ||
|
||
document.head.appendChild(styleTag); | ||
} | ||
} | ||
|
||
function generateUnuseStyleTagFn(styleTag) { | ||
return () => { | ||
if (document.head.contains(styleTag)) { | ||
document.head.removeChild(styleTag); | ||
} | ||
}; | ||
} | ||
|
||
export default (content) => { | ||
const styleTag = createStyleTag(content); | ||
return { use: generateUseStyleTagFn(styleTag), unuse: generateUnuseStyleTagFn(styleTag) }; | ||
} |
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,48 +1,5 @@ | ||
<link rel="shortcut icon" href="/favicon.ico" /> | ||
<link rel="icon" type="image/svg" href="/logo.svg" sizes="192x192" /> | ||
|
||
<script type="text/javascript" src="preview-head.js"></script> | ||
<script src="https://unpkg.com/focus-visible@5.1.0/dist/focus-visible.js"></script> | ||
|
||
<style type="text/css"> | ||
@font-face { | ||
font-family: '72'; | ||
src: url('./theming-base-content/content/Base/baseLib/baseTheme/fonts/72-Regular.woff') format('woff'); | ||
font-weight: normal; | ||
font-style: normal; | ||
} | ||
|
||
@font-face { | ||
font-family: '72'; | ||
src: url('./theming-base-content/content/Base/baseLib/baseTheme/fonts/72-Light.woff') format('woff'); | ||
font-weight: 300; | ||
font-style: normal; | ||
} | ||
|
||
@font-face { | ||
font-family: '72'; | ||
src: url('./theming-base-content/content/Base/baseLib/baseTheme/fonts/72-Bold.woff') format('woff'); | ||
font-weight: 700; | ||
font-style: normal; | ||
} | ||
|
||
@font-face { | ||
font-family: 'SAP-icons'; | ||
src: url('./theming-base-content/content/Base/baseLib/sap_horizon/fonts/SAP-icons.woff') format('woff'); | ||
font-weight: normal; | ||
font-style: normal; | ||
} | ||
|
||
@font-face { | ||
font-family: 'BusinessSuiteInAppSymbols'; | ||
src: url('./theming-base-content/content/Base/baseLib/baseTheme/fonts/BusinessSuiteInAppSymbols.woff') format('woff'); | ||
font-weight: normal; | ||
font-style: normal; | ||
} | ||
|
||
@font-face { | ||
font-family: 'SAP-icons-TNT'; | ||
src: url('./theming-base-content/content/Base/baseLib/baseTheme/fonts/SAP-icons-TNT.woff') format('woff'); | ||
font-weight: normal; | ||
font-style: normal; | ||
} | ||
</style> |