Skip to content

Commit dc6f94e

Browse files
feat(ThemingParameters): Switch to offical Theme Designer Parameters (#348)
Closes #240
1 parent d31cf5c commit dc6f94e

File tree

62 files changed

+1041
-353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1041
-353
lines changed

config/jest.config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@ module.exports = {
66
coverageReporters: ['lcov', 'text'],
77
collectCoverage: false,
88
collectCoverageFrom: [
9-
'packages/**/*.{ts,tsx}',
9+
'packages/{base,charts,main}/src/**/*.{ts,tsx}',
1010
'!**/src/lib/*',
1111
'!**/src/interfaces/*',
1212
'!**/src/enums/*',
1313
'!**/*.stories.tsx',
1414
'!**/*.jss.ts',
1515
'!**/node_modules/**',
1616
'!packages/*/src/index.ts',
17-
'!packages/*/index.ts',
18-
'!packages/cra-template/**/*',
1917
'!packages/**/demo/*',
2018
'!packages/base/src/polyfill/*', // no polyfills
21-
'!packages/main/src/components/AnalyticalTable/types/*' // no table enums
19+
'!packages/main/src/components/AnalyticalTable/types/*', // no table enums
20+
'!packages/base/src/styling/sap_fiori_3.ts', // no old theming parameters
21+
'!packages/base/src/styling/HSLColor.ts', // no deprecated HSL Util
22+
'!packages/base/src/styling/font72.ts' // no deprecated font
2223
],
2324
setupFiles: ['jest-canvas-mock'],
2425
setupFilesAfterEnv: ['./config/jestsetup.ts'],

docs/styling/MyCustomElement.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import { createUseStyles } from 'react-jss';
33

44
const styles = ({ parameters }) => ({
55
container: {
6-
backgroundColor: parameters.sapUiGlobalBackgroundColor,
7-
fontFamily: parameters.sapUiFontFamily,
6+
backgroundColor: parameters.sapBackgroundColor,
7+
fontFamily: parameters.sapFontFamily,
88
height: '50px',
99
display: 'flex',
1010
justifyContent: 'center',
1111
alignItems: 'center'
1212
},
1313
text: {
14-
color: parameters.sapUiNegativeText,
15-
fontSize: parameters.sapUiFontLargeSize
14+
color: parameters.sapNegativeTextColor,
15+
fontSize: parameters.sapFontLargeSize
1616
}
1717
});
1818

docs/styling/MyCustomElement.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { JSSTheme } from '@ui5/webcomponents-react/src/interfaces/JSSTheme';
1+
import { JSSTheme } from '@ui5/webcomponents-react/interfaces/JSSTheme';
22
import React from 'react';
33
import { createUseStyles } from 'react-jss';
44

55
const styles = ({ parameters }: JSSTheme) => ({
66
container: {
7-
backgroundColor: parameters.sapUiGlobalBackgroundColor,
8-
fontFamily: parameters.sapUiFontFamily,
7+
backgroundColor: parameters.sapBackgroundColor,
8+
fontFamily: parameters.sapFontFamily,
99
height: '50px',
1010
display: 'flex',
1111
justifyContent: 'center',
1212
alignItems: 'center'
1313
},
1414
text: {
15-
color: parameters.sapUiNegativeText,
16-
fontSize: parameters.sapUiFontLargeSize
15+
color: parameters.sapNegativeTextColor,
16+
fontSize: parameters.sapFontLargeSize
1717
}
1818
});
1919

docs/welcome/Styling.stories.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Per default, we are injecting the Fiori 3 theme parameters as CSS Variables into
1414
If you want to change e.g. the color of all texts, you can do that by creating another `style` element with the following content:
1515
```html
1616
<style>
17-
--sapUiBaseText: limegreen;
17+
--sapTextColor: limegreen;
1818
</style>
1919
```
2020
As a consequence, all HTML Elements in the subtree where this style was applied are now displaying their texts in `limegreen` instead of `#32363a` which would be the default value for Fiori 3.
@@ -46,16 +46,16 @@ import { createUseStyles } from 'react-jss';
4646
4747
const styles = ({ parameters }) => ({
4848
container: {
49-
backgroundColor: parameters.sapUiGlobalBackgroundColor,
50-
fontFamily: parameters.sapUiFontFamily,
49+
backgroundColor: parameters.sapBackgroundColor,
50+
fontFamily: parameters.sapFontFamily,
5151
height: '50px',
5252
display: 'flex',
5353
justifyContent: 'center',
5454
alignItems: 'center'
5555
},
5656
text: {
57-
color: parameters.sapUiNegativeText,
58-
fontSize: parameters.sapUiFontLargeSize
57+
color: parameters.sapNegativeTextColor,
58+
fontSize: parameters.sapFontLargeSize
5959
}
6060
})
6161
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
const { writeFileSync } = require('fs');
2-
const {
3-
_: Fiori3ThemingVariables
4-
} = require('@ui5/webcomponents/dist/assets/themes/sap_fiori_3/parameters-bundle.css.json');
2+
const { root } = require('./themeDesignerVariables');
53
const PATHS = require('../../../../config/paths');
64
const path = require('path');
75

8-
const variables = Fiori3ThemingVariables.replace(':root{', '')
9-
.replace(/}$/, '')
10-
.split(';')
11-
.filter((variable) => !/^--_?ui5/.test(variable))
12-
.map((value) => value.split(':')[0]);
6+
const variables = Object.keys(root);
137

14-
let fileContent = `/*
8+
let fileContent = `/* eslint-disable camelcase */
9+
10+
/*
1511
* ### WARNING ###
1612
* This is an autogenerated file, do not change manually.
1713
* In order to recreate this file, please run 'node packages/base/scripts/cssVariables/parse.js'
1814
*/
1915
2016
`;
2117

18+
fileContent += 'export const ThemingParameters = {\n';
2219
for (const variable of variables) {
23-
fileContent += `export const ${variable.replace('--', '')} = 'var(${variable})';\n`;
20+
fileContent += ` '${variable}': 'var(--${variable})',\n`;
2421
}
22+
fileContent += '}\n';
2523

26-
writeFileSync(path.join(PATHS.packages, 'base', 'src', 'styling', 'sap_fiori_3.ts'), fileContent);
24+
writeFileSync(path.join(PATHS.packages, 'base', 'src', 'styling', 'ThemingParameters.ts'), fileContent);

0 commit comments

Comments
 (0)