File tree Expand file tree Collapse file tree 4 files changed +63
-1
lines changed Expand file tree Collapse file tree 4 files changed +63
-1
lines changed Original file line number Diff line number Diff line change
1
+ import '../../components/VersionSwitch.js' ;
Original file line number Diff line number Diff line change
1
+ import { IconButton } from '@storybook/components' ;
2
+ import { addons , types } from '@storybook/manager-api' ;
3
+ import { ActionSheet , Button , ThemeProvider } from '@ui5/webcomponents-react' ;
4
+ import * as React from 'react' ;
5
+
6
+ const ADDON_ID = 'version-switch' ;
7
+ const TOOL_ID = `${ ADDON_ID } /toolbar` ;
8
+
9
+ addons . register ( ADDON_ID , ( api ) => {
10
+ addons . add ( TOOL_ID , {
11
+ type : types . TOOLEXTRA ,
12
+ title : 'Version Switch' ,
13
+ render : ( ) => {
14
+ const [ open , setOpen ] = React . useState ( false ) ;
15
+
16
+ const handleVersionSelect = ( e ) => {
17
+ const { slug } = e . target . dataset ;
18
+ window . location . href = `https://sap.github.io/ui5-webcomponents-react/${ slug } /` ;
19
+ } ;
20
+
21
+ const activeVersionSlug =
22
+ window . location . pathname . replace ( '/ui5-webcomponents-react/' , '' ) . replaceAll ( '/' , '' ) || 'nightly' ;
23
+ const activeVersion = activeVersionSlug . at ( 0 ) . toUpperCase ( ) + activeVersionSlug . slice ( 1 ) ;
24
+ return (
25
+ < ThemeProvider >
26
+ < IconButton
27
+ active
28
+ key = { TOOL_ID }
29
+ id = { TOOL_ID }
30
+ title = "Version Switch"
31
+ style = { { order : - 1 } }
32
+ onClick = { ( ) => {
33
+ setOpen ( true ) ;
34
+ } }
35
+ >
36
+ Version: { activeVersion }
37
+ </ IconButton >
38
+ < ActionSheet
39
+ placementType = "Bottom"
40
+ open = { open }
41
+ opener = { TOOL_ID }
42
+ onAfterClose = { ( ) => {
43
+ setOpen ( false ) ;
44
+ } }
45
+ >
46
+ < Button onClick = { handleVersionSelect } data-slug = { 'v2' } >
47
+ Version 2
48
+ </ Button >
49
+ < Button onClick = { handleVersionSelect } data-slug = { 'v1' } >
50
+ Version 1
51
+ </ Button >
52
+ < Button onClick = { handleVersionSelect } data-slug = { 'nightly' } >
53
+ 🚧 Nightly
54
+ </ Button >
55
+ </ ActionSheet >
56
+ </ ThemeProvider >
57
+ ) ;
58
+ }
59
+ } ) ;
60
+ } ) ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { isChromatic } from './utils';
6
6
const isDevMode = process . env . NODE_ENV === 'development' ;
7
7
8
8
const addons = [
9
+ './addons/version-switch' ,
9
10
{
10
11
name : '@storybook/addon-essentials' ,
11
12
options : {
Original file line number Diff line number Diff line change 11
11
"start:storybook" : " storybook dev -p 6006" ,
12
12
"setup" : " lerna run build:i18n && lerna run build:css && lerna run build:css-bundle && rimraf node_modules/@types/mocha" ,
13
13
"build" : " yarn setup && tsc --build && lerna run build:client && lerna run build:wrapper && lerna run build:ssr" ,
14
- "build:storybook" : " lerna run build:i18n && yarn create-cypress-commands-docs && storybook build -o .out" ,
14
+ "build:storybook" : " yarn build && yarn create-cypress-commands-docs && storybook build -o .out" ,
15
15
"build:storybook-sitemap" : " node ./scripts/create-storybook-sitemap.js --directory .out" ,
16
16
"test:prepare" : " rimraf temp && lerna run build" ,
17
17
"test:cypress" : " cypress run --component --browser chrome" ,
You can’t perform that action at this time.
0 commit comments