1
1
import { select , withKnobs } from '@storybook/addon-knobs' ;
2
2
import { makeDecorator } from '@storybook/addons' ;
3
3
import { addDecorator , addParameters } from '@storybook/react' ;
4
+ import { setTheme } from '@ui5/webcomponents-base/dist/config/Theme' ;
4
5
import '@ui5/webcomponents-base/dist/features/browsersupport/IE11' ;
6
+ import '@ui5/webcomponents-fiori/dist/json-imports/Themes' ;
5
7
import '@ui5/webcomponents-react-base/polyfill/IE11' ;
6
8
import { ContentDensity } from '@ui5/webcomponents-react/lib/ContentDensity' ;
7
9
import { ThemeProvider } from '@ui5/webcomponents-react/lib/ThemeProvider' ;
8
10
import { Themes } from '@ui5/webcomponents-react/lib/Themes' ;
9
11
import '@ui5/webcomponents/dist/json-imports/i18n' ;
12
+ import '@ui5/webcomponents/dist/json-imports/Themes' ;
10
13
import '@webcomponents/webcomponentsjs/webcomponents-bundle' ;
11
14
import { window } from 'global' ;
12
15
import 'highlight.js/styles/solarized-dark.css' ;
13
16
import qs from 'qs' ;
14
17
import React , { useEffect } from 'react' ;
15
18
import 'react-app-polyfill/ie11' ;
16
- import '@ui5/webcomponents/dist/json-imports/Themes' ;
17
- import '@ui5/webcomponents-fiori/dist/json-imports/Themes' ;
18
- import { setTheme } from '@ui5/webcomponents-base/dist/config/Theme' ;
19
19
20
20
addParameters ( {
21
21
options : {
@@ -30,7 +30,7 @@ addParameters({
30
30
31
31
addDecorator ( withKnobs ) ;
32
32
33
- const ThemeContainer = ( { theme, contentDensity, children, setQueryParam } ) => {
33
+ const ThemeContainer = ( { theme, contentDensity, children, setQueryParam, direction } ) => {
34
34
useEffect ( ( ) => {
35
35
if ( contentDensity === ContentDensity . Compact ) {
36
36
document . body . classList . add ( 'ui5-content-density-compact' ) ;
@@ -39,6 +39,10 @@ const ThemeContainer = ({ theme, contentDensity, children, setQueryParam }) => {
39
39
}
40
40
} , [ contentDensity , setQueryParam ] ) ;
41
41
42
+ useEffect ( ( ) => {
43
+ document . querySelector ( 'html' ) . setAttribute ( 'dir' , direction . toLowerCase ( ) ) ;
44
+ } , [ direction ] ) ;
45
+
42
46
useEffect ( ( ) => {
43
47
setTheme ( theme ) ;
44
48
} , [ theme ] ) ;
@@ -73,6 +77,7 @@ const withQuery = makeDecorator({
73
77
< ThemeContainer
74
78
theme = { select ( 'Theme' , [ Themes . sap_fiori_3 , Themes . sap_fiori_3_dark ] , Themes . sap_fiori_3 ) }
75
79
contentDensity = { select ( 'ContentDensity' , ContentDensity , contentDensity ) }
80
+ direction = { select ( 'Text Direction' , [ 'LTR' , 'RTL' ] , 'LTR' ) }
76
81
setQueryParam = { setQueryParam }
77
82
>
78
83
{ getStory ( context ) }
0 commit comments