1- import type { Preview , WebComponentsRenderer } from '@storybook/web-components' ;
2- import { withThemeByClassName } from '@storybook/addon-themes' ;
1+ import type { Preview } from '@storybook/web-components-vite' ;
32
4- import * as tmp from '../dist/browser/index' ;
5- console . log ( tmp ) ;
6-
7-
8- import * as EmberNexus from '@ember-nexus/web-sdk' ;
93import './style.css?style' ;
104import './preview.css?style' ;
11- import { init } from '@ember-nexus/app-core' ;
125
13- const WebSdkConfiguration = EmberNexus . Service . WebSdkConfiguration ;
14- const container = EmberNexus . Container ;
15- container . get ( WebSdkConfiguration ) . setApiHost ( 'https://reference-dataset.ember-nexus.dev' ) ;
16- container . get ( WebSdkConfiguration ) . setToken ( 'secret-token:PIPeJGUt7c00ENn8a5uDlc' as EmberNexus . Type . Definition . Token ) ;
17- container . get ( EmberNexus . BrowserEvent . BrowserEventHandler ) . addBrowserEventListeners ( document . body as HTMLElement ) ;
18- console . log ( document . body ) ;
6+ import { init as appPluginExperimentalInit } from '../dist/browser/index.js' ;
7+ // import * as appPluginExperimental from '../dist/browser/index.js';
8+ // console.log(appPluginExperimental);
9+
10+ // import appPluginExperimental = require('../dist/browser/index.js');
11+ // console.log(appPluginExperimental);
12+ //
13+ // const appPluginExperimentalInit = appPluginExperimental.init;
14+
1915
20- const serviceResolver = init ( document . body ) ;
16+ // import {init as appPluginExperimentalInit} from '../dist/browser/index';
17+
18+
19+ import { init as appCoreInit } from '@ember-nexus/app-core' ;
20+ import { ApiConfiguration } from "@ember-nexus/app-core/Service" ;
21+ import { withTheme } from "./withTheme.decorator" ;
22+
23+ const serviceResolver = appCoreInit ( document . body ) ;
2124( window as any ) . serviceResolver = serviceResolver ;
2225
26+ const apiConfiguration = serviceResolver . getServiceOrFail < ApiConfiguration > ( ApiConfiguration . identifier ) ;
27+ apiConfiguration . setApiHost ( 'https://reference-dataset.ember-nexus.dev' ) ;
28+ apiConfiguration . setToken ( 'secret-token:PIPeJGUt7c00ENn8a5uDlc' as any ) ;
29+
30+ appPluginExperimentalInit ( serviceResolver ) ;
31+
32+ const themeService = serviceResolver . getServiceOrFail ( 'ember-nexus.app-plugin-experimental.service.theme-service' ) ;
33+ const languageService = serviceResolver . getServiceOrFail ( 'ember-nexus.app-plugin-experimental.service.language-service' ) ;
34+
35+
36+ const globalTypes = {
37+ locale : {
38+ name : "Language" ,
39+ defaultValue : "en" ,
40+ toolbar : {
41+ icon : "globe" ,
42+ items : [
43+ // default language
44+ { value : "en" , right : "EN" , title : "English" } ,
45+
46+ // core languages
47+ { value : "de" , right : "DE" , title : "German" } ,
48+ { value : "no" , right : "NO" , title : "Norwegian" } ,
49+ { value : "ko" , right : "KO" , title : "Korean" } ,
50+
51+ // additional languages
52+ { value : "ar" , right : "AR" , title : "Arabic" } ,
53+ { value : "zh-CN" , right : "ZH-CN" , title : "Chinese" } ,
54+ { value : "fr" , right : "FR" , title : "French" } ,
55+ { value : "hi" , right : "HI" , title : "Hindi" } ,
56+ { value : "it" , right : "IT" , title : "Italian" } ,
57+ { value : "ja" , right : "JA" , title : "Japanese" } ,
58+ { value : "ru" , right : "RU" , title : "Russian" } ,
59+ { value : "es" , right : "ES" , title : "Spanish" } ,
60+ { value : "sw" , right : "SW" , title : "Swahili" } ,
61+ ] ,
62+ title : "Language" ,
63+ dynamicTitle : true
64+ }
65+ }
66+ } ;
67+
2368const preview : Preview = {
2469 parameters : {
2570 controls : {
@@ -30,21 +75,29 @@ const preview: Preview = {
3075 } ,
3176 options : {
3277 storySort : ( a , b ) => {
33- return a . id === b . id ? 0 : a . id . localeCompare ( b . id , undefined , { numeric : true } ) ;
78+ return a . id === b . id ? 0 : a . id . localeCompare ( b . id , undefined , { numeric : true } ) ;
3479 }
3580 } ,
3681 layout : 'centered' ,
3782 } ,
3883 decorators : [
39- withThemeByClassName < WebComponentsRenderer > ( {
84+ withTheme ( {
4085 themes : {
41- light : '' ,
86+ light : 'light ' ,
4287 dark : 'dark' ,
43- 'high contrast' : 'high-contrast'
88+ emerald : 'emerald' ,
89+ dim : 'dim' ,
4490 } ,
4591 defaultTheme : 'light' ,
92+ themeService : themeService
4693 } ) ,
94+ ( story , context ) => {
95+ const { locale } = context . globals ;
96+ // @ts -ignore
97+ languageService . applyLanguage ( locale ) ;
98+ return story ( ) ;
99+ }
47100 ] ,
48101} ;
49-
102+ export { globalTypes } ;
50103export default preview ;
0 commit comments