Skip to content

Commit 9309505

Browse files
refactor(base): Merge styles and utils into base (#38)
BREAKING CHANGE `@ui5-webcomponents-react/styles` and `@ui5-webcomponents-react/utils` are replaced by ``@ui5-webcomponents-react/base` BREAKING CHANGE Deleted Themes `sap_belize`, `sap_belize_plus` and `sap_belize_hcb` BREAKING CHANGE Removed `createThemeMap` from base BREAKING CHANGE Removed `getThemeClassFor` from base BREAKING CHANGE Removed `getThemeOverwrite` from base BREAKING CHANGE Deleted `Themes` from base Closes #34
1 parent cf53d38 commit 9309505

File tree

297 files changed

+1451
-2834
lines changed

Some content is hidden

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

297 files changed

+1451
-2834
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ yarn-error.log
55
.idea
66
coverage
77
/.env
8-
lib/
98
dist/
109
@types
1110
typings
1211
!/typings
1312
.cache
14-
!packages/utils/src/Device/lib
15-
!packages/fiori3/src/lib
1613
build
1714
/packages/*/npm/**/*.d.ts
1815
.out

README.md

Lines changed: 5 additions & 10 deletions

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
2828
"@babel/preset-env": "^7.4.4",
2929
"@babel/preset-react": "^7.0.0",
30-
"@storybook/addon-actions": "^5.0.11",
31-
"@storybook/addon-info": "^5.0.11",
32-
"@storybook/addon-knobs": "^5.0.11",
33-
"@storybook/addon-options": "^5.0.11",
34-
"@storybook/addons": "^5.0.11",
35-
"@storybook/react": "^5.0.11",
30+
"@storybook/addon-actions": "^5.1.9",
31+
"@storybook/addon-info": "^5.1.9",
32+
"@storybook/addon-knobs": "^5.1.9",
33+
"@storybook/addon-options": "^5.1.9",
34+
"@storybook/addons": "^5.1.9",
35+
"@storybook/react": "^5.1.9",
3636
"@storybook/storybook-deployer": "^2.8.1",
37-
"@storybook/theming": "^5.0.11",
37+
"@storybook/theming": "^5.1.9",
3838
"@types/chai": "^4.1.7",
3939
"@types/enzyme": "^3.9.3",
4040
"@types/hoist-non-react-statics": "^3.3.1",
@@ -85,7 +85,6 @@
8585
"karma-mocha": "^1.3.0",
8686
"karma-mocha-reporter": "^2.2.5",
8787
"karma-mocha-snapshot": "^0.2.1",
88-
"karma-selenium-grid-launcher": "^0.2.0",
8988
"karma-snapshot": "^0.6.0",
9089
"karma-sourcemap-loader": "^0.3.7",
9190
"karma-webpack": "^3.0.5",

packages/utils/README.md renamed to packages/base/README.md

Lines changed: 5 additions & 5 deletions
File renamed without changes.

packages/base/npm/index.cjs.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./cjs/base.production.min.js');
5+
} else {
6+
module.exports = require('./cjs/base.development.js');
7+
}

packages/base/npm/index.esm.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./esm/base.production.min.js');
5+
} else {
6+
module.exports = require('./esm/base.development.js');
7+
}
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
{
2-
"name": "@ui5-webcomponents-react/styles",
2+
"name": "@ui5-webcomponents-react/base",
33
"version": "0.3.2-rc.2",
4-
"description": "Stylesheets for ui5-webcomponents-react",
4+
"description": "Base for ui5-webcomponents-react",
55
"main": "index.cjs.js",
66
"module": "index.esm.js",
77
"types": "index.d.ts",
8-
"repository": "https://github.com/SAP/ui5-webcomponents-react/tree/master/packages/styles",
8+
"repository": "https://github.com/SAP/ui5-webcomponents-react/tree/master/packages/base",
99
"author": "SAP SE (https://www.sap.com)",
1010
"license": "Apache-2.0",
1111
"dependencies": {
12-
"core-js": "^3.1.3",
12+
"core-js": "^3.1.4",
13+
"tslib": "^1.9.3",
1314
"deepmerge": "^3.2.0",
1415
"hoist-non-react-statics": "^3.3.0",
1516
"react-jss": "^8.6.1"
16-
},
17-
"peerDependencies": {
18-
"react": "^16.8.0"
1917
}
2018
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/base/src/HSLColor.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { HSLColor } from './HSLColor';
2+
import { sapColorSemanticNegative, sapUiBrand, sapUiHighlight } from './sap_fiori_3';
3+
4+
describe('HSL Color', () => {
5+
test('lighten', () => {
6+
const color = HSLColor.of(sapUiHighlight).lighten(63).hsl;
7+
expect(color).toEqual('hsl(209.8, 90.9%, 95%)'); //hsl(208.4, 90.5%, 95.9%)
8+
});
9+
10+
test('darken', () => {
11+
const color = HSLColor.of(sapUiBrand).darken(10).hsl;
12+
expect(color).toEqual('hsl(209.8, 90.9%, 32.9%)'); //hsl(210, 90.5%, 32.9%)
13+
});
14+
15+
test('border bg colors', () => {
16+
const color = HSLColor.of(sapColorSemanticNegative).lighten(59.5).hsl;
17+
expect(color).toEqual('hsl(0, 100%, 95.5%)'); //hsl(0, 100%, 96.1%)
18+
});
19+
});
File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/utils/src/Logger.ts renamed to packages/base/src/Logger.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ class DeviceLogger {
3939
component: sComponent || ''
4040
};
4141
if (window.console) {
42-
const logText = `${oLogEntry.date} ${oLogEntry.time} ${this.sWindowName}${oLogEntry.message} - ${
43-
oLogEntry.component
44-
}`;
42+
const logText = `${oLogEntry.date} ${oLogEntry.time} ${this.sWindowName}${oLogEntry.message} - ${oLogEntry.component}`;
4543
switch (iLevel) {
4644
case LOG_LEVEL.FATAL:
4745
case LOG_LEVEL.ERROR:
File renamed without changes.

packages/utils/src/Util.ts renamed to packages/base/src/Util.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,3 @@
1-
import Themes from './Themes';
2-
3-
type ThemeMap = { [theme in Themes]: object };
4-
5-
export const getThemeClassFor = (theme: Themes, themes: ThemeMap) => {
6-
if ({}.hasOwnProperty.call(themes, theme)) {
7-
return themes[theme];
8-
}
9-
throw new Error('Could not match theme to Theme Class!');
10-
};
11-
12-
/**
13-
* Create a Theme Map for given styles
14-
* @param light {object} Belize Theme CSS Module
15-
* @param dark {object} Belize Deep Theme CSS Module
16-
* @param hcb {object} High Contrast Black Theme CSS Module
17-
* @return {ThemeMap} Theme Map
18-
*/
19-
export const createThemeMap = (light: object, dark: object, hcb: object = {}): ThemeMap => ({
20-
[Themes.sap_belize]: light,
21-
[Themes.sap_belize_plus]: dark,
22-
[Themes.sap_belize_hcb]: hcb
23-
});
24-
25-
/**
26-
* Get overwrite theme class
27-
* @param {string} theme
28-
* @param {string} overwrite
29-
* @return {string} Theme String
30-
*
31-
*/
32-
export const getThemeOverwrite = (theme: Themes, overwrite: Themes): Themes => {
33-
if ((Object as any).values(Themes).includes(overwrite)) return overwrite;
34-
return theme;
35-
};
36-
371
export const deprecationNotice = (component: string, message: string) => {
382
const value = `* ui5-webcomponents-react Deprecation Notice - ${component}`;
393
const dots = '*'.padStart(value.length, '*');
File renamed without changes.
File renamed without changes.
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
/**
22
* Created by d059190 at 16.03.18
33
*/
4+
import font72 from './72';
5+
import { bootstrap } from './bootstrap';
6+
import * as fonts from './fonts';
7+
import { HSLColor } from './HSLColor';
8+
import * as sap_fiori_3 from './sap_fiori_3';
9+
import * as spacing from './spacing';
10+
import { withStyles } from './withStyles';
11+
import { Device } from './Device';
412
import { Event } from './Event';
13+
import { isNumeric } from './isNumeric';
514
import KeyCodes from './KeyCodes';
615
import { LOG_LEVEL, Logger } from './Logger';
716
import Optional from './Optional';
817
import StyleClassHelper from './StyleClassHelper';
9-
import Themes from './Themes';
10-
import { isNumeric } from './isNumeric';
11-
import { Device } from './Device';
1218

13-
import {
14-
createThemeMap,
15-
deprecationNotice,
16-
getThemeClassFor,
17-
getThemeOverwrite,
18-
pushElementBackInScreen
19-
} from './Util';
19+
import { deprecationNotice, pushElementBackInScreen } from './Util';
2020

2121
export {
2222
StyleClassHelper,
2323
KeyCodes,
2424
Optional,
25-
getThemeClassFor,
26-
createThemeMap,
27-
getThemeOverwrite,
2825
deprecationNotice,
2926
pushElementBackInScreen,
30-
Themes,
3127
Event,
3228
Logger,
3329
LOG_LEVEL,
3430
isNumeric,
35-
Device
31+
Device,
32+
fonts,
33+
font72,
34+
spacing,
35+
HSLColor,
36+
sap_fiori_3,
37+
bootstrap,
38+
withStyles
3639
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/charts/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"@types/chart.js": "^2.7.53"
1414
},
1515
"dependencies": {
16-
"@ui5-webcomponents-react/styles": "0.3.2-rc.2",
17-
"@ui5-webcomponents-react/utils": "0.3.2-rc.2",
16+
"@ui5-webcomponents-react/base": "0.3.2-rc.2",
1817
"chart.js": "^2.8.0",
1918
"chartjs-plugin-datalabels": "^0.6.0",
2019
"is-mergeable-object": "^1.1.0",

packages/charts/src/components/BarChart/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { DEFAULT_OPTIONS } from '../../config';
66
import { formatTooltipLabel, getTextWidth, mergeConfig } from '../../util/utils';
77
import { ChartBaseProps } from '../../interfaces/ChartBaseProps';
88
import { ChartBaseDefaultProps } from '../../util/ChartBaseDefaultProps';
9-
import { LOG_LEVEL, Logger } from '@ui5-webcomponents-react/utils';
9+
import { LOG_LEVEL, Logger } from '@ui5-webcomponents-react/base';
1010
import { withChartContainer } from '../ChartContainer/withChartContainer';
1111
import { BarChartPlaceholder } from './Placeholder';
1212

packages/charts/src/components/ChartContainer/withChartContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { ComponentType } from 'react';
2-
import { withStyles } from '@ui5-webcomponents-react/styles';
2+
import { withStyles } from '@ui5-webcomponents-react/base';
33
import hoistNonReactStatics from 'hoist-non-react-statics';
44
import { DEFAULT_OPTIONS } from '../../config';
55
import { ChartBaseProps } from '../../interfaces/ChartBaseProps';

packages/charts/src/components/Loader/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { withStyles } from '@ui5-webcomponents-react/styles';
1+
import { withStyles } from '@ui5-webcomponents-react/base';
22
import * as React from 'react';
33
import { LoaderStyles } from './Loader.jss';
44

packages/charts/src/components/MicroBarChart/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { withStyles } from '@ui5-webcomponents-react/styles';
1+
import { withStyles } from '@ui5-webcomponents-react/base';
22
import React, { CSSProperties, PureComponent } from 'react';
33
import { ChartInternalProps } from '../../interfaces/ChartInternalProps';
44
import { CommonProps } from '../../interfaces/CommonProps';

packages/charts/src/components/RadarChart/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ChartInternalProps } from '../../interfaces/ChartInternalProps';
55
import { formatTooltipLabel, mergeConfig } from '../../util/utils';
66
import { ChartBaseProps } from '../../interfaces/ChartBaseProps';
77
import { ChartBaseDefaultProps } from '../../util/ChartBaseDefaultProps';
8-
import { HSLColor } from '@ui5-webcomponents-react/styles';
8+
import { HSLColor } from '@ui5-webcomponents-react/base';
99
import { withChartContainer } from '../ChartContainer/withChartContainer';
1010

1111
export interface RadarChartPropTypes extends ChartBaseProps {}

packages/charts/src/components/RadialChart/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { StyleClassHelper } from '@ui5-webcomponents-react/utils';
2-
import { withStyles } from '@ui5-webcomponents-react/styles';
1+
import { StyleClassHelper, withStyles } from '@ui5-webcomponents-react/base';
32
import { ChartOptions } from 'chart.js';
43
import React, { CSSProperties, PureComponent, Ref } from 'react';
54
import { ChartInternalProps } from '../../interfaces/ChartInternalProps';

packages/cli/src/create-f4r-component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const jsxSpinner = ora('Creating index.tsx').start();
3939
// create jsx
4040
const jsxContent = `
4141
import React, { Component, ComponentClass } from 'react';
42-
import { withStyles } from '@ui5-webcomponents-react/utils';
42+
import { withStyles } from '@ui5-webcomponents-react/base';
4343
import styles from './${componentName}.jss';
4444
import { ClassProps } from '../../types/ClassProps';
4545

packages/docs/.storybook/webpack.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ SKIP_DOC_GENERATION=true
5959
'@shared': path.join(PATHS.root, 'shared'),
6060
'@ui5-webcomponents-react/fiori3': path.join(PATHS.root, 'packages', 'fiori3', 'src', 'index.ts'),
6161
'@ui5-webcomponents-react/charts': path.join(PATHS.root, 'packages', 'charts', 'src', 'index.ts'),
62-
'@ui5-webcomponents-react/utils': path.join(PATHS.root, 'packages', 'utils', 'src', 'index.ts'),
63-
'@ui5-webcomponents-react/styles': path.join(PATHS.root, 'packages', 'styles', 'src', 'index.ts')
62+
'@ui5-webcomponents-react/base': path.join(PATHS.root, 'packages', 'base', 'src', 'index.ts')
6463
}
6564
}
6665
};

packages/fiori3/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
"test:karma:update": "cross-env UPDATE=1 yarn run test:karma"
1717
},
1818
"dependencies": {
19-
"@ui5-webcomponents-react/styles": "0.3.2-rc.2",
20-
"@ui5-webcomponents-react/utils": "0.3.2-rc.2",
19+
"@ui5-webcomponents-react/base": "0.3.2-rc.2",
2120
"@ui5/webcomponents": "0.12.0",
22-
"core-js": "^2.6.4",
2321
"react-scroll": "^1.7.11",
2422
"react-toastify": "^5.0.1"
2523
},

packages/fiori3/scripts/wrapperGeneration/generateTypingsWeb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export function generateTypings(meta) {
214214
.forEach(([key]) => {
215215
typings[mapEventName(key)] = {
216216
tsType: '(event : Event) => void',
217-
importStatement: "import { Event } from '@ui5-webcomponents-react/utils';"
217+
importStatement: "import { Event } from '@ui5-webcomponents-react/base';"
218218
};
219219
});
220220

packages/fiori3/scripts/wrapperGeneration/generateWebComponentWrappers.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ async function generateWebComponentWrapper(dto) {
4040
'\n\n',
4141
tsTypings.interfaceStatement,
4242
'\n\n',
43-
`const ${componentName}: FC<${tsTypings.interfaceName}> = withWebComponent<${
44-
tsTypings.interfaceName
45-
}>(${ui5ComponentName});`,
43+
`const ${componentName}: FC<${tsTypings.interfaceName}> = withWebComponent<${tsTypings.interfaceName}>(${ui5ComponentName});`,
4644
'\n\n',
4745
`${componentName}.displayName = '${componentName}';`,
4846
'\n\n',
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<html>
3-
<body>
4-
<script src="dist/build.js"></script>
5-
</body>
3+
<body>
4+
<script src="dist/build.js"></script>
5+
</body>
66
</html>

packages/fiori3/scripts/wrapperGeneration/puppeteerScript.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { generateTypings } from './generateTypingsWeb';
2+
23
const modules = require('./json/modules');
34

45
modules.forEach((moduleName) => {

packages/fiori3/scripts/wrapperGeneration/showOptions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { generateDiff } from './diff';
2+
23
const inquirer = require('inquirer');
34
const fs = require('fs');
45
const chalk = require('chalk');

0 commit comments

Comments
 (0)