diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx
index aed8833..5b96a65 100644
--- a/.storybook/preview.tsx
+++ b/.storybook/preview.tsx
@@ -1,9 +1,10 @@
import React from 'react';
import type { Preview } from '@storybook/react';
import { action } from '@storybook/addon-actions';
+import { useGlobals, useParameter } from '@storybook/manager-api';
import { ThemeContextProvider, testables } from '../src/Contexts';
import { MemoryRouter } from 'react-router';
-import { DEFAULT_THEME } from '../src/theme';
+import { DEFAULT_THEME, THEME_LIST, getSetting } from '../src/theme';
const { ConfigurationContext } = testables;
@@ -16,6 +17,25 @@ const preview: Preview = {
date: /Date$/i,
},
},
+ backgrounds: {
+ disable: true,
+ },
+ },
+
+ globalTypes: {
+ theme: {
+ description: 'Global theme for components',
+ defaultValue: 'Visual Studio', //DEFAULT_THEME.name,
+ toolbar: {
+ // The label to show for this toolbar item
+ title: 'Theme',
+ icon: 'circlehollow',
+ // Array of plain string values or MenuItem shape (see below)
+ items: Object.keys(THEME_LIST),
+ // Change title based on selected value
+ dynamicTitle: true,
+ },
+ },
},
decorators: [
(Story) => (
@@ -23,23 +43,48 @@ const preview: Preview = {
),
- (Story) => (
- {
- action('addConnectionToConfig')(connection);
- },
- }}
- >
-
-
-
-
+ (Story, { globals: { theme } }) => {
+ // const themeName = useParameter('backgrounds');
+
+ // console.log('themeName', themeName);
+
+ return (
+ {
+ action('addConnectionToConfig')(connection);
+ },
+ }}
+ >
+
+
+
+
+ );
+ },
+ // force storybook background to be the same as the theme
+ (Story, { globals: { theme } }) => (
+ <>
+
+
+ >
),
],
};
diff --git a/src/Contexts.tsx b/src/Contexts.tsx
index 2e28a49..3ce7783 100644
--- a/src/Contexts.tsx
+++ b/src/Contexts.tsx
@@ -1,5 +1,5 @@
import { createContext, useContext, useEffect, useState } from 'react';
-import { ThemeProvider } from 'styled-components';
+import styled, { ThemeProvider } from 'styled-components';
import { ConfigProvider, theme as antdTheme } from 'antd';
import { Configuration } from './configuration/type';
import {
@@ -65,6 +65,15 @@ export function useTheme() {
return useContext(ThemeContext);
}
+const LayoutDiv = styled.div`
+ width: 100%;
+ height: 100vh;
+ display: flex;
+ flex-direction: column;
+ background: ${(props) => getSetting(props.theme, 'background')};
+ color: ${(props) => getSetting(props.theme, 'foreground')};
+`;
+
export function ThemeContextProvider({
children,
}: {
@@ -106,7 +115,7 @@ export function ThemeContextProvider({
},
}}
>
- {children}
+ {children}
diff --git a/src/routes/root.tsx b/src/routes/root.tsx
index ec9dbf6..6f470bc 100644
--- a/src/routes/root.tsx
+++ b/src/routes/root.tsx
@@ -5,18 +5,9 @@ import {
ThemeContextProvider,
} from '../Contexts';
import styled from 'styled-components';
-import { getSetting } from '../theme';
import Debug from '../component/Debug';
import ThemeSelector from '../component/ThemeSelector';
-const LayoutDiv = styled.div`
- width: 100%;
- height: 100vh;
- display: flex;
- flex-direction: column;
- background: ${(props) => getSetting(props.theme, 'background')};
- color: ${(props) => getSetting(props.theme, 'foreground')};
-`;
const HeaderDiv = styled.header`
display: flex;
justify-content: space-between;
@@ -29,17 +20,15 @@ export default function Root() {
-
-
+
-
- Welcome to Tiana Tables !
-
- Theme:
-
-
-
-
+
+ Welcome to Tiana Tables !
+
+ Theme:
+
+
+