File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Expand file tree Collapse file tree 3 files changed +58
-0
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 } 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
+ return (
21
+ < >
22
+ < IconButton
23
+ active
24
+ key = { TOOL_ID }
25
+ id = { TOOL_ID }
26
+ title = "Version Switch"
27
+ style = { { order : - 1 } }
28
+ onClick = { ( ) => {
29
+ setOpen ( true ) ;
30
+ } }
31
+ >
32
+ Version
33
+ </ IconButton >
34
+ < ActionSheet
35
+ placement = "Bottom"
36
+ open = { open }
37
+ opener = { TOOL_ID }
38
+ onClose = { ( ) => {
39
+ setOpen ( false ) ;
40
+ } }
41
+ >
42
+ < Button onClick = { handleVersionSelect } data-slug = { 'v2' } >
43
+ Version 2
44
+ </ Button >
45
+ < Button onClick = { handleVersionSelect } data-slug = { 'v1' } >
46
+ Version 1
47
+ </ Button >
48
+ < Button onClick = { handleVersionSelect } data-slug = { 'nightly' } >
49
+ 🚧 Nightly
50
+ </ Button >
51
+ </ ActionSheet >
52
+ </ >
53
+ ) ;
54
+ }
55
+ } ) ;
56
+ } ) ;
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 : {
You can’t perform that action at this time.
0 commit comments