Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove extensions to be included by default and enhance flexibility of custom styles import #24

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ function ThemeProvider({ children }) {
// (optional) defines with a glob where the styles are placed inside of @dnb/eufemia/...
filesGlobs: [
'**/style/dnb-ui-core.min.css',
'**/style/themes/**/*-theme-{basis,components,extensions}.min.css',
'**/style/themes/**/*-theme-{basis,components}.min.css',
],

// (optional) The file order does matter. Define a glob inside an array.
includeFiles: [
'**/dnb-ui-core.*',
'**/*-theme-extensions.*',
'**/*-theme-components.*',
'**/*-theme-basis.*',
],
Expand All @@ -79,9 +78,6 @@ function ThemeProvider({ children }) {
// (optional) when set to false, your app will not be wrapped with the needed `<Theme>` provider.
wrapWithThemeProvider: true,

// (optional) when set to false, your app will have to import the core styles (dnb-ui-core) by yourself.
coreStyleName: 'dnb-ui-core',

// (optional) when set to true, the page scroll behaviour will not be effected.
omitScrollBehavior: false,

Expand Down
13 changes: 2 additions & 11 deletions packages/gatsby-plugin-eufemia-theme-handler/src/collectThemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export function createThemesImport({

return { file, themeName }
})
.filter(({ themeName }) => {
return limitThemes.length === 0 || limitThemes.includes(themeName)
.filter(({ file }) => {
return !/\/(cjs|es|esm)\//.test(file)
})
.sort((a, b) => {
return (
Expand All @@ -86,15 +86,6 @@ export function createThemesImport({
)
})

if (pluginOptions.coreStyleName) {
const coreFile = importFiles.find((file) =>
file.includes(pluginOptions.coreStyleName)
)
if (coreFile) {
sortedImportFiles.unshift({ file: coreFile })
}
}

if (pluginOptions.verbose) {
reporter.info(
`sortedImportFiles:\n${sortedImportFiles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ exports.pluginOptionsSchema = ({ Joi }) => {
.optional()
.default([
'**/style/dnb-ui-core.min.css',
'**/style/themes/**/*-theme-{basis,components,extensions}.min.css',
'**/style/themes/**/*-theme-{basis,components}.min.css',
]),
includeFiles: Joi.array().optional().default([
// The file order does matter!
'**/dnb-ui-core.*',
'**/*-theme-extensions.*',
'**/*-theme-components.*',
'**/*-theme-basis.*',
]),
inlineDefaultTheme: Joi.boolean().optional().default(true),
wrapWithThemeProvider: Joi.boolean().optional().default(true),
coreStyleName: Joi.string().optional().default('dnb-ui-core'),
omitScrollBehavior: Joi.boolean().optional().default(false),
verbose: Joi.boolean().optional().default(false),
})
Expand Down