Skip to content

Commit

Permalink
Revert "Merge branch 'master' into chore/update-storybook"
Browse files Browse the repository at this point in the history
This reverts commit 1b801f9, reversing
changes made to 1106f34.
  • Loading branch information
kleinju1017 committed May 27, 2020
1 parent 1b801f9 commit d3daed6
Show file tree
Hide file tree
Showing 44 changed files with 667 additions and 2,854 deletions.
40 changes: 6 additions & 34 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { highlightLog } = require('../scripts/utils');
const path = require('path');
const PATHS = require('../config/paths');
const dedent = require('dedent');
require('dotenv').config({
path: path.join(PATHS.root, '.env')
});
Expand All @@ -15,7 +13,12 @@ const DEPENDENCY_REGEX = BUILD_FOR_IE11

module.exports = {
stories: ['../docs/**/*.stories.mdx', '../packages/**/*.stories.mdx', '../packages/**/*.stories.[tj]sx'],
addons: ['@storybook/addon-knobs', '@storybook/addon-docs', '@storybook/addon-actions'],
addons: [
'@storybook/addon-toolbars',
'@storybook/addon-docs',
'@storybook/addon-controls',
'@storybook/addon-actions'
],
webpack: async (config, { configType }) => {
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
// You can change the configuration based on that.
Expand All @@ -27,35 +30,6 @@ module.exports = {
type: 'javascript/auto'
});

const tsLoader = {
test: /\.tsx?$/,
include: PATHS.packages,
use: [
{
loader: require.resolve('babel-loader'),
options: {
envName: 'esm',
configFile: path.resolve(PATHS.root, 'babel.config.js')
}
}
]
};

if (IS_RELEASE_BUILD) {
highlightLog('Warning: Prop Types Table Generation is active');
tsLoader.use.push(require.resolve('react-docgen-typescript-loader'));
} else {
highlightLog('Info: Prop Types Table Generation is disabled');
console.log(dedent`
The Prop Table Generation is very expensive during build-time and therefore disabled by default.
If you need Prop-Tables, you can activate it by adding a '.env' file to the root of the project with the following content:
UI5_WEBCOMPONENTS_FOR_REACT_RELEASE_BUILD=true\n\n
`);
}

config.module.rules.push(tsLoader);

if ((IS_RELEASE_BUILD && configType === 'PRODUCTION') || BUILD_FOR_IE11) {
config.module.rules.push({
test: /\.(js|mjs)$/,
Expand Down Expand Up @@ -102,8 +76,6 @@ module.exports = {
}
});
}

config.resolve.extensions.push('.ts', '.tsx');
config.resolve.alias = {
...config.resolve.alias,
'@shared': path.join(PATHS.root, 'shared'),
Expand Down
90 changes: 80 additions & 10 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { select, withKnobs } from '@storybook/addon-knobs';
import { makeDecorator } from '@storybook/addons';
import { addDecorator, addParameters } from '@storybook/react';
import { setTheme } from '@ui5/webcomponents-base/dist/config/Theme';
Expand All @@ -23,11 +22,11 @@ addParameters({
: a[1].id.localeCompare(b[1].id, undefined, { numeric: true, caseFirst: 'upper' });
},
showRoots: true
}
},
passArgsFirst: true,
actions: { argTypesRegex: '^on.*' }
});

addDecorator(withKnobs);

const ThemeContainer = ({ theme, contentDensity, children, direction }) => {
useEffect(() => {
if (contentDensity === ContentDensity.Compact) {
Expand All @@ -37,9 +36,9 @@ const ThemeContainer = ({ theme, contentDensity, children, direction }) => {
}
}, [contentDensity]);

// useEffect(() => {
// document.querySelector('html').setAttribute('dir', direction.toLowerCase());
// }, [direction]);
useEffect(() => {
document.querySelector('html').setAttribute('dir', direction);
}, [direction]);

useEffect(() => {
setTheme(theme);
Expand All @@ -54,9 +53,9 @@ const withQuery = makeDecorator({
wrapper: (getStory, context) => {
return (
<ThemeContainer
theme={select('Theme', Themes, Themes.sap_fiori_3)}
contentDensity={select('ContentDensity', ContentDensity, ContentDensity.Cozy)}
direction={select('Text Direction', ['LTR', 'RTL'], 'LTR')}
theme={context.globalArgs.theme || Themes.sap_fiori_3}
contentDensity={context.globalArgs.contentDensity}
direction={context.globalArgs.direction}
>
{getStory(context)}
</ThemeContainer>
Expand All @@ -65,3 +64,74 @@ const withQuery = makeDecorator({
});

addDecorator(withQuery);

export const globalArgTypes = {
theme: {
name: 'Theme',
description: 'Fiori Theme',
defaultValue: Themes.sap_fiori_3,
toolbar: {
icon: 'paintbrush',
items: [
{
value: Themes.sap_fiori_3,
title: Themes.sap_fiori_3
},
{
value: Themes.sap_fiori_3_dark,
title: Themes.sap_fiori_3_dark
},
{
value: Themes.sap_belize,
title: Themes.sap_belize
},
{
value: Themes.sap_belize_hcb,
title: Themes.sap_belize_hcb
},
{
value: Themes.sap_belize_hcw,
title: Themes.sap_belize_hcw
}
]
}
},
contentDensity: {
name: 'Content Density',
description: 'Content Density',
defaultValue: ContentDensity.Cozy,
toolbar: {
icon: 'component',
items: [
{
value: ContentDensity.Cozy,
title: ContentDensity.Cozy
},
{
value: ContentDensity.Compact,
title: ContentDensity.Compact
}
]
}
},
direction: {
name: 'Direction',
description: 'Text Direction',
defaultValue: 'ltr',
toolbar: {
icon: 'transfer',
items: [
{
value: 'ltr',
title: 'LTR',
icon: 'arrowrightalt'
},
{
value: 'rtl',
title: 'RTL',
icon: 'arrowleftalt'
}
]
}
}
};
17 changes: 0 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.10.0-rc.1](https://github.com/SAP/ui5-webcomponents-react/compare/v0.10.0-rc.0...v0.10.0-rc.1) (2020-05-25)


### Bug Fixes

* **AnalyticalTable:** remove padding and scrollbar from select-all header cell ([#536](https://github.com/SAP/ui5-webcomponents-react/issues/536)) ([97158a3](https://github.com/SAP/ui5-webcomponents-react/commit/97158a39663cf40c424829a86962df7070a0dacb)), closes [#532](https://github.com/SAP/ui5-webcomponents-react/issues/532)
* **DurationPicker:** use correct value for defaultProp maxValue ([#529](https://github.com/SAP/ui5-webcomponents-react/issues/529)) ([888d069](https://github.com/SAP/ui5-webcomponents-react/commit/888d069a86784c4833f9257abc67e569be3dd231))


### Features

* **StyleClassHelper:** add putIfPresent method ([#539](https://github.com/SAP/ui5-webcomponents-react/issues/539)) ([0ae0785](https://github.com/SAP/ui5-webcomponents-react/commit/0ae078554dd0e7e6a1424de6755ec02fa15bb12e))





# [0.10.0-rc.0](https://github.com/SAP/ui5-webcomponents-react/compare/v0.9.5...v0.10.0-rc.0) (2020-05-19)


Expand Down
1 change: 0 additions & 1 deletion config/jestsetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { createSerializer } from 'enzyme-to-json';
import ResizeObserver from 'resize-observer-polyfill';
import 'intersection-observer';
import '@ui5/webcomponents/dist/generated/json-imports/i18n';
import 'whatwg-fetch';

// React 16 Enzyme adapter
Enzyme.configure({ adapter: new Adapter() });
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "0.10.0-rc.1",
"version": "0.10.0-rc.0",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@
"targz": "^1.0.1",
"tmp": "^0.1.0",
"tslint": "^6.1.2",
"typescript": "^3.8.3",
"whatwg-fetch": "^3.0.0"
"typescript": "^3.8.3"
},
"resolutions": {
"@types/react": "16.9.34",
Expand Down
11 changes: 0 additions & 11 deletions packages/base/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.10.0-rc.1](https://github.com/SAP/ui5-webcomponents-react/compare/v0.10.0-rc.0...v0.10.0-rc.1) (2020-05-25)


### Features

* **StyleClassHelper:** add putIfPresent method ([#539](https://github.com/SAP/ui5-webcomponents-react/issues/539)) ([0ae0785](https://github.com/SAP/ui5-webcomponents-react/commit/0ae078554dd0e7e6a1424de6755ec02fa15bb12e))





# [0.10.0-rc.0](https://github.com/SAP/ui5-webcomponents-react/compare/v0.9.5...v0.10.0-rc.0) (2020-05-19)


Expand Down
2 changes: 1 addition & 1 deletion packages/base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ui5/webcomponents-react-base",
"version": "0.10.0-rc.1",
"version": "0.10.0-rc.0",
"description": "Base for ui5-webcomponents-react",
"main": "index.cjs.js",
"module": "index.esm.js",
Expand Down
32 changes: 6 additions & 26 deletions packages/base/src/hooks/useI18nBundle.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,20 @@
import { fetchI18nBundle, getI18nBundle } from '@ui5/webcomponents-base/dist/i18nBundle';
import { useEffect, useState } from 'react';

type TextWithDefault = { key: string; defaultText: string };
type TextWithPlaceholders = [TextWithDefault, ...string[]];

interface I18nBundle {
getText: (textObj: TextWithDefault, ...args: any) => string;
getText: (textObj: { key: string; defaultText: string }, ...args: any) => string;
}

const resolveTranslations = (bundle, texts) => {
return texts.map((text) => {
if (Array.isArray(text)) {
const [key, ...replacements] = text;
return bundle.getText(key, replacements);
}
return bundle.getText(text);
});
};

export const useI18nText = (bundleName: string, ...texts: (TextWithDefault | TextWithPlaceholders)[]): string[] => {
const i18nBundle: I18nBundle = getI18nBundle(bundleName);
const [translations, setTranslations] = useState(resolveTranslations(i18nBundle, texts));
export const useI18nBundle = (bundleName): I18nBundle => {
const [bundle, setBundle] = useState(getI18nBundle(bundleName));

useEffect(() => {
const fetchAndLoadBundle = async () => {
await fetchI18nBundle(bundleName);
setTranslations((prev) => {
const next = resolveTranslations(i18nBundle, texts);
if (prev.length === next.length && prev.every((translation, index) => next[index] === translation)) {
return prev;
}
return next;
});
setBundle(getI18nBundle(bundleName));
};
fetchAndLoadBundle();
}, [fetchI18nBundle, bundleName, texts]);
}, []);

return translations;
return bundle;
};
4 changes: 2 additions & 2 deletions packages/base/src/lib/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useConsolidatedRef } from '../hooks/useConsolidatedRef';
import { useI18nText } from '../hooks/useI18nBundle';
import { useI18nBundle } from '../hooks/useI18nBundle';
import { usePassThroughHtmlProps } from '../hooks/usePassThroughHtmlProps';
import { useViewportRange } from '../hooks/useViewportRange';

export { useConsolidatedRef, usePassThroughHtmlProps, useViewportRange, useI18nText };
export { useConsolidatedRef, usePassThroughHtmlProps, useViewportRange, useI18nBundle };
3 changes: 0 additions & 3 deletions packages/base/src/styling/CssSizeVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export enum CssSizeVariablesNames {
sapWcrAnalyticalTableTreePaddingLevel1 = 'sapWcrAnalyticalTableTreePaddingLevel1',
sapWcrAnalyticalTableTreePaddingLevel2 = 'sapWcrAnalyticalTableTreePaddingLevel2',
sapWcrAnalyticalTableTreePaddingLevel3 = 'sapWcrAnalyticalTableTreePaddingLevel3',
sapWcrCheckBoxWidthHeight = 'sapWcrCheckBoxWidthHeight',
sapWcrAnalyticalTableSelectionColumnWidth = 'sapWcrAnalyticalTableSelectionColumnWidth'
}

Expand Down Expand Up @@ -43,7 +42,6 @@ export const cssVariablesStyles = `
--${CssSizeVariablesNames.sapWcrAnalyticalTableTreePaddingLevel1}:1.5rem;
--${CssSizeVariablesNames.sapWcrAnalyticalTableTreePaddingLevel2}:2.25rem;
--${CssSizeVariablesNames.sapWcrAnalyticalTableTreePaddingLevel3}:2.75rem;
--${CssSizeVariablesNames.sapWcrCheckBoxWidthHeight}:2.75rem;
--${CssSizeVariablesNames.sapWcrAnalyticalTableSelectionColumnWidth}:55px;
}
Expand All @@ -65,7 +63,6 @@ export const cssVariablesStyles = `
--${CssSizeVariablesNames.sapWcrAnalyticalTableTreePaddingLevel1}:1rem;
--${CssSizeVariablesNames.sapWcrAnalyticalTableTreePaddingLevel2}:1.5rem;
--${CssSizeVariablesNames.sapWcrAnalyticalTableTreePaddingLevel3}:2rem;
--${CssSizeVariablesNames.sapWcrCheckBoxWidthHeight}:2rem;
--${CssSizeVariablesNames.sapWcrAnalyticalTableSelectionColumnWidth}:40px;
}
`;
31 changes: 0 additions & 31 deletions packages/base/src/styling/StyleClassHelper.test.ts

This file was deleted.

Loading

0 comments on commit d3daed6

Please sign in to comment.