-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #554 from alejofernandez/ulx-430
feat: add support for branding themes (no-code tool) [ULX-430]
- Loading branch information
Showing
16 changed files
with
1,218 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,49 @@ | ||
import path from 'path'; | ||
import { ensureDirSync } from 'fs-extra'; | ||
import { getFiles, dumpJSON, loadJSON, existsMustBeDir } from '../../../utils'; | ||
import { DirectoryHandler } from '.'; | ||
import DirectoryContext from '..'; | ||
import { ParsedAsset } from '../../../types'; | ||
import { Theme } from '../../../tools/auth0/handlers/themes'; | ||
import { constants } from '../../../tools'; | ||
|
||
type ParsedThemes = ParsedAsset<'themes', Theme[]>; | ||
|
||
function parse(context: DirectoryContext): ParsedThemes { | ||
const baseFolder = path.join(context.filePath, constants.THEMES_DIRECTORY); | ||
if (!existsMustBeDir(baseFolder)) { | ||
return { themes: null }; | ||
} | ||
|
||
const themeDefinitionsFiles = getFiles(baseFolder, ['.json']); | ||
if (!themeDefinitionsFiles.length) { | ||
return { themes: [] }; | ||
} | ||
|
||
const themes = themeDefinitionsFiles.map( | ||
(themeDefinitionsFile) => loadJSON(themeDefinitionsFile, context.mappings) as Theme | ||
); | ||
|
||
return { themes }; | ||
} | ||
|
||
async function dump(context: DirectoryContext): Promise<void> { | ||
const { themes } = context.assets; | ||
if (!themes) { | ||
return; | ||
} | ||
|
||
const baseFolder = path.join(context.filePath, constants.THEMES_DIRECTORY); | ||
ensureDirSync(baseFolder); | ||
|
||
themes.forEach((themeDefinition, i) => { | ||
dumpJSON(path.join(baseFolder, `theme${i ? i : ''}.json`), themeDefinition); | ||
}); | ||
} | ||
|
||
const themesHandler: DirectoryHandler<ParsedThemes> = { | ||
parse, | ||
dump, | ||
}; | ||
|
||
export default themesHandler; |
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,23 @@ | ||
import { YAMLHandler } from '.'; | ||
import YAMLContext from '..'; | ||
import { ParsedAsset } from '../../../types'; | ||
import { Theme } from '../../../tools/auth0/handlers/themes'; | ||
|
||
type ParsedThemes = ParsedAsset<'themes', Theme[]>; | ||
|
||
async function parseAndDump(context: YAMLContext): Promise<ParsedThemes> { | ||
const { themes } = context.assets; | ||
|
||
if (!themes) return { themes: null }; | ||
|
||
return { | ||
themes, | ||
}; | ||
} | ||
|
||
const themesHandler: YAMLHandler<ParsedThemes> = { | ||
parse: parseAndDump, | ||
dump: parseAndDump, | ||
}; | ||
|
||
export default themesHandler; |
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
Oops, something went wrong.