diff --git a/.storybook/contexts.js b/.storybook/contexts.js index 23268b91..66bb49df 100644 --- a/.storybook/contexts.js +++ b/.storybook/contexts.js @@ -3,11 +3,11 @@ // FIXME: not yet tested, as we wait for Storybook v6.0.0 official release import darkTheme from "~/lib/style/darkTheme"; import defaultTheme from "~/lib/style/defaultTheme"; -import { SCThemeProvider } from "~/src/components/providers/SCThemeProvider"; +import { MuiThemeProvider } from "~/src/components/providers/MuiThemeProvider"; export const contexts = [ { title: "Theme", - components: [SCThemeProvider], + components: [MuiThemeProvider], params: [ { name: "Default theme", diff --git a/cypress/integration/integration/mui-styled-components.spec.ts b/cypress/integration/integration/mui-styled-components.spec.ts index abae0755..d0fd2de5 100644 --- a/cypress/integration/integration/mui-styled-components.spec.ts +++ b/cypress/integration/integration/mui-styled-components.spec.ts @@ -2,8 +2,8 @@ const orange = "rgb(255, 166, 22)"; // hex color will be translated to RGB during render so directly testing the HEX value won't work describe("material-ui", () => { describe("ssr", () => { - it("does render a button with styled components applied", () => { - cy.visit("/vns/debug/sc-mui"); + it("does render a button with emotion styles applied", () => { + cy.visit("/vns/debug/emotion-mui"); cy.get("button", { timeout: 0 }).should( "have.css", "background-color", diff --git a/package.json b/package.json index 92d25aab..62b07373 100644 --- a/package.json +++ b/package.json @@ -95,8 +95,6 @@ "react-hook-form": "4.9.8", "react-i18next": "^11.5.0", "react-spring": "^8.0.27", - "styled-components": "5.1.1", - "styled-components-modifiers": "^1.2.5", "styled-jsx-plugin-postcss": "^3.0.2", "swr": "^0.4.0" }, @@ -108,7 +106,6 @@ "@types/react": "^16.9.23", "@types/react-dom": "^16.9.5", "@types/shelljs": "^0.8.8", - "@types/styled-components": "^5.1.0", "@typescript-eslint/eslint-plugin": "^2.21.0", "@typescript-eslint/parser": "^2.21.0", "babel-eslint": "^10.1.0", diff --git a/packages/@vulcanjs/next-styled-components/dist/getSCDocumentInitialProps.d.ts b/packages/@vulcanjs/next-styled-components/dist/getSCDocumentInitialProps.d.ts deleted file mode 100644 index 1c036e16..00000000 --- a/packages/@vulcanjs/next-styled-components/dist/getSCDocumentInitialProps.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import { AppSheetsCollector } from "@vulcanjs/next-style-collector"; -export declare const getAppEnhancer: () => AppSheetsCollector; diff --git a/packages/@vulcanjs/next-styled-components/dist/index.d.ts b/packages/@vulcanjs/next-styled-components/dist/index.d.ts deleted file mode 100644 index a5ba2348..00000000 --- a/packages/@vulcanjs/next-styled-components/dist/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./getSCDocumentInitialProps"; diff --git a/packages/@vulcanjs/next-styled-components/dist/index.js b/packages/@vulcanjs/next-styled-components/dist/index.js deleted file mode 100644 index b619c2da..00000000 --- a/packages/@vulcanjs/next-styled-components/dist/index.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(1),t)},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getAppEnhancer=void 0;const o=r(n(2)),u=n(3);t.getAppEnhancer=()=>{const e=new u.ServerStyleSheet;return{sheets:e,enhanceApp:t=>n=>e.collectStyles(o.default.createElement(t,Object.assign({},n))),finally:()=>e.seal()}}},function(e,t){e.exports=require("react")},function(e,t){e.exports=require("styled-components")}]); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vLy4vaW5kZXgudHMiLCJ3ZWJwYWNrOi8vLy4vZ2V0U0NEb2N1bWVudEluaXRpYWxQcm9wcy50c3giLCJ3ZWJwYWNrOi8vL2V4dGVybmFsIFwicmVhY3RcIiIsIndlYnBhY2s6Ly8vZXh0ZXJuYWwgXCJzdHlsZWQtY29tcG9uZW50c1wiIl0sIm5hbWVzIjpbImluc3RhbGxlZE1vZHVsZXMiLCJfX3dlYnBhY2tfcmVxdWlyZV9fIiwibW9kdWxlSWQiLCJleHBvcnRzIiwibW9kdWxlIiwiaSIsImwiLCJtb2R1bGVzIiwiY2FsbCIsIm0iLCJjIiwiZCIsIm5hbWUiLCJnZXR0ZXIiLCJvIiwiT2JqZWN0IiwiZGVmaW5lUHJvcGVydHkiLCJlbnVtZXJhYmxlIiwiZ2V0IiwiciIsIlN5bWJvbCIsInRvU3RyaW5nVGFnIiwidmFsdWUiLCJ0IiwibW9kZSIsIl9fZXNNb2R1bGUiLCJucyIsImNyZWF0ZSIsImtleSIsImJpbmQiLCJuIiwib2JqZWN0IiwicHJvcGVydHkiLCJwcm90b3R5cGUiL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AgdHJ5IHtcbiAgICBjdHgucmVuZGVyUGFnZSA9ICgpID0+XG4gICAgICBvcmlnaW5hbFJlbmRlclBhZ2Uoe1xuICAgICAgICBlbmhhbmNlQXBwOiAoQXBwKSA9PiAocHJvcHMpID0+IHNoZWV0LmNvbGxlY3RTdHlsZXMoPEFwcCB7Li4ucHJvcHN9IC8+KSxcbiAgICAgIH0pO1xuXG4gICAgLy8gZ2V0IHBhcmVudCBwcm9wc1xuICAgIC8vIE5PVEU6IHdlIG5lZWQgdG8gaGF2ZSBhbHJlYWR5IGVuaGFuY2VkIGN0eCwgc28gaXQgaGFzIHRvIGJlIGRvbmUgaGVyZVxuICAgIGNvbnN0IGluaXRpYWxQcm9wcyA9IGF3YWl0IERvY3VtZW50LmdldEluaXRpYWxQcm9wcyhjdHgpO1xuICAgIHJldHVybiB7XG4gICAgICAuLi5pbml0aWFsUHJvcHMsXG4gICAgICBzdHlsZXM6IChcbiAgICAgICAgPD5cbiAgICAgICAgICB7aW5pdGlhbFByb3BzLnN0eWxlc31cbiAgICAgICAgICB7c2hlZXQuZ2V0U3R5bGVFbGVtZW50KCl9XG4gICAgICAgIDwvPlxuICAgICAgKSxcbiAgICB9O1xuICB9IGZpbmFsbHkge1xuICAgIHNoZWV0LnNlYWwoKTtcbiAgfVxufTtcbmV4cG9ydCBkZWZhdWx0IGdldFNDRG9jdW1lbnRJbml0aWFsUHJvcHM7XG4qL1xuIiwibW9kdWxlLmV4cG9ydHMgPSByZXF1aXJlKFwicmVhY3RcIik7IiwibW9kdWxlLmV4cG9ydHMgPSByZXF1aXJlKFwic3R5bGVkLWNvbXBvbmVudHNcIik7Il0sInNvdXJjZVJvb3QiOiIifQ== \ No newline at end of file diff --git a/packages/@vulcanjs/next-styled-components/dist/next-style-collector/index.d.ts b/packages/@vulcanjs/next-styled-components/dist/next-style-collector/index.d.ts deleted file mode 100644 index 2188ff84..00000000 --- a/packages/@vulcanjs/next-styled-components/dist/next-style-collector/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface AppSheetsCollector { - sheets: { - getStyleElement: Function; - }; - enhanceApp: Function; - finally?: Function; -} diff --git a/packages/@vulcanjs/next-styled-components/dist/next-styled-components/getSCDocumentInitialProps.d.ts b/packages/@vulcanjs/next-styled-components/dist/next-styled-components/getSCDocumentInitialProps.d.ts deleted file mode 100644 index 1c036e16..00000000 --- a/packages/@vulcanjs/next-styled-components/dist/next-styled-components/getSCDocumentInitialProps.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import { AppSheetsCollector } from "@vulcanjs/next-style-collector"; -export declare const getAppEnhancer: () => AppSheetsCollector; diff --git a/packages/@vulcanjs/next-styled-components/dist/next-styled-components/index.d.ts b/packages/@vulcanjs/next-styled-components/dist/next-styled-components/index.d.ts deleted file mode 100644 index a5ba2348..00000000 --- a/packages/@vulcanjs/next-styled-components/dist/next-styled-components/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./getSCDocumentInitialProps"; diff --git a/packages/@vulcanjs/next-styled-components/getSCDocumentInitialProps.tsx b/packages/@vulcanjs/next-styled-components/getSCDocumentInitialProps.tsx deleted file mode 100644 index 71a764c7..00000000 --- a/packages/@vulcanjs/next-styled-components/getSCDocumentInitialProps.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import React from "react"; -import { ServerStyleSheet } from "styled-components"; -import { AppSheetsCollector } from "@vulcanjs/next-style-collector"; - -export const getAppEnhancer = (): AppSheetsCollector => { - const sheet = new ServerStyleSheet(); - const enhanceApp = (App) => (props) => - (sheet as any).collectStyles(); - return { - sheets: sheet, // MUI and Styled components have non normalized types, so we renormalize the names - enhanceApp, - finally: () => sheet.seal(), - }; -}; -// @see https://github.com/vercel/next.js/blob/canary/examples/with-styled-components/pages/_document.js -// This function do not generalize when you have another lib collecting stylesheets (eg Material UI) -/* -const getSCDocumentInitialProps = async (ctx: DocumentContext) => { - const sheet = new ServerStyleSheet(); - const originalRenderPage = ctx.renderPage; - - try { - ctx.renderPage = () => - originalRenderPage({ - enhanceApp: (App) => (props) => sheet.collectStyles(), - }); - - // get parent props - // NOTE: we need to have already enhanced ctx, so it has to be done here - const initialProps = await Document.getInitialProps(ctx); - return { - ...initialProps, - styles: ( - <> - {initialProps.styles} - {sheet.getStyleElement()} - - ), - }; - } finally { - sheet.seal(); - } -}; -export default getSCDocumentInitialProps; -*/ diff --git a/packages/@vulcanjs/next-styled-components/index.ts b/packages/@vulcanjs/next-styled-components/index.ts deleted file mode 100644 index a5ba2348..00000000 --- a/packages/@vulcanjs/next-styled-components/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./getSCDocumentInitialProps"; diff --git a/packages/@vulcanjs/next-styled-components/package.json b/packages/@vulcanjs/next-styled-components/package.json deleted file mode 100644 index a69cf429..00000000 --- a/packages/@vulcanjs/next-styled-components/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "@vulcanjs/next-styled-components", - "version": "0.0.1", - "description": "Vulcan Next Styled Components bindings", - "main": "./dist/index.js", - "author": "eric-burel ", - "homepage": "https://github.com/VulcanJS/vulcan-npm#readme", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/VulcanJS/vulcan-npm.git" - }, - "scripts": { - "test": "echo \"Error: run tests from root\" && exit 1", - "build": "webpack --config ./webpack.config.js" - }, - "bugs": { - "url": "https://github.com/VulcanJS/vulcan-npm/issues" - }, - "dependencies": { - "react": "^16.13.1", - "styled-components": "^5.2.0" - } -} diff --git a/packages/@vulcanjs/next-styled-components/tsconfig.json b/packages/@vulcanjs/next-styled-components/tsconfig.json deleted file mode 100644 index eefb7f57..00000000 --- a/packages/@vulcanjs/next-styled-components/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../../tsconfig.json", - "compilerOptions": { - "outDir": "./dist" - }, - "include": ["*.ts"] -} diff --git a/packages/@vulcanjs/next-styled-components/webpack.config.js b/packages/@vulcanjs/next-styled-components/webpack.config.js deleted file mode 100644 index af370835..00000000 --- a/packages/@vulcanjs/next-styled-components/webpack.config.js +++ /dev/null @@ -1,10 +0,0 @@ -const merge = require("webpack-merge"); -const path = require("path"); -const baseConfig = require("../../webpack/webpack.config.base.common.prod"); -//const merge = require('webpack-merge') -module.exports = merge(baseConfig, { - entry: path.resolve(__dirname, "./index.ts"), - output: { - path: path.resolve(__dirname, "dist"), - }, -}); diff --git a/src/components/providers/MuiThemeProvider.tsx b/src/components/providers/MuiThemeProvider.tsx index 9a489b8b..cacf108d 100644 --- a/src/components/providers/MuiThemeProvider.tsx +++ b/src/components/providers/MuiThemeProvider.tsx @@ -1,5 +1,5 @@ import { ThemeProvider } from "@material-ui/core/styles"; -import defaultTheme from "~/lib/material-ui/defaultTheme"; +import defaultTheme from "~/lib/style/defaultTheme"; import React, { createContext, useContext, useState } from "react"; type UseMuiThemeOutput = [Object, (newTheme: Object) => void]; @@ -8,7 +8,10 @@ const useMuiTheme = (): UseMuiThemeOutput => { return [muiTheme, setMuiTheme]; }; -const MuiThemeContext = createContext(undefined); +const MuiThemeContext = createContext([ + defaultTheme, + () => {}, +]); /** * Can be called anywhere, will provide current theme @@ -16,7 +19,7 @@ const MuiThemeContext = createContext(undefined); * * Internally use "useState" to remember the current theme. */ -export const useMuiThemeContext = (): UseMuiThemeOutput | undefined => { +export const useMuiThemeContext = (): UseMuiThemeOutput => { return useContext(MuiThemeContext); }; diff --git a/src/components/providers/SCThemeProvider.tsx b/src/components/providers/SCThemeProvider.tsx.deprecated similarity index 100% rename from src/components/providers/SCThemeProvider.tsx rename to src/components/providers/SCThemeProvider.tsx.deprecated diff --git a/src/components/providers/index.ts b/src/components/providers/index.ts index 16835703..594f2d8e 100644 --- a/src/components/providers/index.ts +++ b/src/components/providers/index.ts @@ -1,2 +1 @@ export * from "./MuiThemeProvider"; -export * from "./SCThemeProvider"; diff --git a/src/components/providers/stories/SCTheme.stories.tsx b/src/components/providers/stories/MuiThemeProvider.stories.tsx similarity index 55% rename from src/components/providers/stories/SCTheme.stories.tsx rename to src/components/providers/stories/MuiThemeProvider.stories.tsx index 3fc52f12..1ab90852 100644 --- a/src/components/providers/stories/SCTheme.stories.tsx +++ b/src/components/providers/stories/MuiThemeProvider.stories.tsx @@ -2,36 +2,36 @@ * Demo of a theme switch button */ import React, { useState } from "react"; -import { useSCThemeContext } from "../SCThemeProvider"; -import styled from "styled-components"; +import { useMuiThemeContext } from "../MuiThemeProvider"; import darkTheme from "~/lib/style/darkTheme"; import defaultTheme from "~/lib/style/defaultTheme"; +import { styled } from "@material-ui/core/styles"; export default { title: "VN/ThemeSwitch", //component: useSCThemeContext // decoractors: [(storyFn) =>
{storyFn()}
}; -const ThemedDiv = styled.div` - color: ${(props) => props.theme.color}; - background-color: ${(props) => props.theme.backgroundColor}; +const ThemedDiv = styled("div")` + color: ${(props) => props.theme.palette.text.primary}; + background-color: ${(props) => props.theme.palette.background.default}; `; const ThemeSwitchDemo = () => { - const [currentSCTheme, setSCTheme] = useSCThemeContext(); + const [currentMuiTheme, setMuiTheme] = useMuiThemeContext(); const [isDark, setIsDark] = useState(false); // default is light - const toggleSCTheme = () => { + const toggleMuiTheme = () => { const nextTheme = isDark ? defaultTheme : darkTheme; - setSCTheme(nextTheme); + setMuiTheme(nextTheme); setIsDark(!isDark); }; return (
- +
Current theme:
-
{JSON.stringify(currentSCTheme, null, 2)}
+
{JSON.stringify(currentMuiTheme, null, 2)}
); }; diff --git a/src/components/ui/StyledComponentsButton.tsx b/src/components/ui/EmotionButton.tsx similarity index 94% rename from src/components/ui/StyledComponentsButton.tsx rename to src/components/ui/EmotionButton.tsx index b51c5679..e421dfa4 100644 --- a/src/components/ui/StyledComponentsButton.tsx +++ b/src/components/ui/EmotionButton.tsx @@ -1,6 +1,6 @@ /** * Demo of a button with some custom style, - * combining styled-components and material-ui + * combining emotion/styled and material-ui * */ // NOTE: you don't need to import React, it will be added at build time by Babel/Next @@ -10,7 +10,7 @@ import { ButtonProps as MuiButtonProps, } from "@material-ui/core"; import colors from "~/lib/style/colors"; -import styled from "styled-components"; +import { styled } from "@material-ui/core/styles"; import { lighten } from "polished"; const technologyToColor = { diff --git a/src/components/ui/Modal.tsx b/src/components/ui/Modal.tsx index e62ff277..3982e4fb 100644 --- a/src/components/ui/Modal.tsx +++ b/src/components/ui/Modal.tsx @@ -5,35 +5,37 @@ * - with react-spring, for physics based animation */ import colors from "~/lib/style/colors"; -import styled from "styled-components"; -import { - applyStyleModifiers, - ModifiersConfig, - ModifiersProp, - ModifierKeys, -} from "styled-components-modifiers"; +import { styled } from "@material-ui/core/styles"; import { useSpring, animated } from "react-spring"; -const MODAL_MODIFIERS: ModifiersConfig = { - // TODO: not style autocompletion - // @see https://github.com/Decisiv/styled-components-modifiers/issues/51 - vulcan: () => ` - background-color: ${colors.orangeVulcan}; - `, - themeDefault: (props) => ` - background-color: ${props.theme.backgroundColor}; - color: ${props.theme.color}; - `, -}; +// Demo using styled components and modifier +// We currently prefer using em +// import { +// applyStyleModifiers, +// ModifiersConfig, +// ModifiersProp, +// ModifierKeys, +// } from "styled-components-modifiers"; +// const MODAL_MODIFIERS: ModifiersConfig = { +// // TODO: not style autocompletion +// // @see https://github.com/Decisiv/styled-components-modifiers/issues/51 +// vulcan: () => ` +// background-color: ${colors.orangeVulcan}; +// `, +// themeDefault: (props) => ` +// background-color: ${props.theme.backgroundColor}; +// color: ${props.theme.color}; +// `, +// }; // This type should be included out-of-the bow in future versions of styled-components-modifiers // @see https://github.com/Decisiv/styled-components-modifiers/pull/52 // @see https://github.com/Decisiv/styled-components-modifiers/pull/53/files -interface WithModifiers { - modifiers?: ModifierKeys; -} +//interface WithModifiers { +// modifiers?: ModifierKeys; +//} -const ModalWrapper = styled(animated.div)` +const ModalWrapper = styled(animated.div)/**/ ` max-width: 800px; height: 500px; box-shadow: 2px 2px 1px 4px ${colors.pinkGraphql}; @@ -42,20 +44,20 @@ const ModalWrapper = styled(animated.div)` justify-content: center; align-items: center; position: relative; - ${applyStyleModifiers(MODAL_MODIFIERS)} `; +// ${applyStyleModifiers(MODAL_MODIFIERS)} -interface ModalProps extends WithModifiers { +interface ModalProps /*extends WithModifiers*/ { children: React.ReactNode; } -export const Modal = ({ children, modifiers }: ModalProps) => { +export const Modal = ({ children /*, modifiers*/ }: ModalProps) => { const animation = useSpring({ opacity: 1, transform: "scale3d(1,1,1)", from: { opacity: 0, transform: "scale3d(1, 0, 1)" }, }); return ( - + {children} ); diff --git a/src/components/ui/stories/button.stories.tsx b/src/components/ui/stories/button.stories.tsx index 4768eb63..d5d5c3c9 100644 --- a/src/components/ui/stories/button.stories.tsx +++ b/src/components/ui/stories/button.stories.tsx @@ -1,5 +1,5 @@ import React from "react"; -import StyledComponentsButton from "../StyledComponentsButton"; +import StyledComponentsButton from "../EmotionButton"; import StyledJSXButton from "../StyledJsxButton"; import { action } from "@storybook/addon-actions"; // Prefer addons-control @@ -15,7 +15,7 @@ const defaultProps = { }; export default { - title: "vns/design-system/Button", + title: "vn/design-system/Button", // decoractors: [(storyFn) =>
{storyFn()}
}; diff --git a/src/components/ui/stories/modal.stories.tsx b/src/components/ui/stories/modal.stories.tsx index 39b87ab5..139a9ad4 100644 --- a/src/components/ui/stories/modal.stories.tsx +++ b/src/components/ui/stories/modal.stories.tsx @@ -25,6 +25,7 @@ basic.story = { // parameters: {...} }; +/** deprecated: we no longer used styled-components modifiers library export const vulcan = () => (
@@ -32,3 +33,4 @@ export const vulcan = () => (
); +*/ diff --git a/src/content/docs/features/styling-and-material-ui.md b/src/content/docs/features/styling-and-material-ui.md index 8327958a..bdc18ac5 100644 --- a/src/content/docs/features/styling-and-material-ui.md +++ b/src/content/docs/features/styling-and-material-ui.md @@ -12,10 +12,6 @@ We try to reduce the footprint of Material UI for an easy remove. In next iterat Previous version of Vulcan Next was already using Styled Components with Material UI v4. Material UI v5 uses Emotion out-of-the-box -#### Styled Components Modifiers - -We demo [Styled Components Modifiers](https://github.com/Decisiv/styled-components-modifiers), a powerful way to add modifiers props on your elements (options like "large", "warning", "dark"...). - ### Theme switch demo We demo a theme switch button, using React context. See `lib/providers` for sources and sample Storybook stories. diff --git a/src/lib/material-ui/defaultTheme.ts b/src/lib/material-ui/defaultTheme.ts deleted file mode 100644 index 91674db5..00000000 --- a/src/lib/material-ui/defaultTheme.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Mui theme -// @see https://material-ui.com/customization/default-theme -// @see https://github.com/mui-org/material-ui/issues/20787 -// @see https://github.com/vercel/styled-jsx/issues/142 -import { createTheme } from "@material-ui/core/styles"; - -// Create a theme instance. -const theme = createTheme({}); - -export default theme; diff --git a/src/lib/style/darkTheme.ts b/src/lib/style/darkTheme.ts index c2b27e90..d4392b0a 100644 --- a/src/lib/style/darkTheme.ts +++ b/src/lib/style/darkTheme.ts @@ -1,5 +1,20 @@ import colors from "./colors"; -export default { - backgroundColor: colors.greyVulcan, - color: colors.white, -}; +// Mui theme +// @see https://material-ui.com/customization/default-theme +// @see https://github.com/mui-org/material-ui/issues/20787 +// @see https://github.com/vercel/styled-jsx/issues/142 +import { createTheme } from "@material-ui/core/styles"; + +// Create a theme instance. +const theme = createTheme({ + palette: { + background: { + default: colors.greyVulcan, + }, + text: { + primary: colors.white, + }, + }, +}); + +export default theme; diff --git a/src/lib/style/defaultTheme.ts b/src/lib/style/defaultTheme.ts index a5eda5ed..2fb5f671 100644 --- a/src/lib/style/defaultTheme.ts +++ b/src/lib/style/defaultTheme.ts @@ -1,5 +1,20 @@ import colors from "./colors"; -export default { - backgroundColor: colors.white, - color: colors.greyVulcan, -}; +// Mui theme +// @see https://material-ui.com/customization/default-theme +// @see https://github.com/mui-org/material-ui/issues/20787 +// @see https://github.com/vercel/styled-jsx/issues/142 +import { createTheme } from "@material-ui/core/styles"; + +// Create a theme instance. +const theme = createTheme({ + palette: { + background: { + default: colors.white, + }, + text: { + primary: colors.greyVulcan, + }, + }, +}); + +export default theme; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index a4649726..9ab11504 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -3,7 +3,7 @@ import App, { AppProps } from "next/app"; import { appWithTranslation } from "~/lib/i18n"; // Comment if you don't need Material UI import { useMuiApp } from "@vulcanjs/next-material-ui"; -import { SCThemeProvider, MuiThemeProvider } from "~/components/providers"; +import { MuiThemeProvider } from "~/components/providers"; import Head from "next/head"; import debug from "debug"; @@ -65,13 +65,11 @@ function VNApp({ Component, pageProps }: AppProps) { - - - - - - - + + + + + ); diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index 0f296e48..da92f508 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -1,5 +1,4 @@ // @see https://github.com/mui-org/material-ui/blob/master/examples/nextjs/pages/_document.js -// @see https://github.com/MarchWorks/nextjs-with-material-ui-and-styled-components import React from "react"; import Document, { Html, @@ -8,15 +7,11 @@ import Document, { NextScript, //DocumentInitialProps, } from "next/document"; -import theme from "~/lib/material-ui/defaultTheme"; +import theme from "~/lib/style/defaultTheme"; import { getAppEnhancer as getMuiAppEnhancer, //getMuiDocumentInitialProps, } from "@vulcanjs/next-material-ui"; -import { - getAppEnhancer as getSCAppEnhancer, - //getSCDocumentInitialProps, -} from "@vulcanjs/next-styled-components"; import { i18nPropsFromCtx, DocumentLanguageProps } from "~/lib/i18n"; interface VNSDocumentProps { @@ -51,8 +46,7 @@ export default class MyDocument extends Document { // it's compatible with server-side generation (SSG). MyDocument.getInitialProps = async (ctx) => { const muiAppEnhancer = getMuiAppEnhancer(); - const scAppEnhancer = getSCAppEnhancer(); - const enhancers = [scAppEnhancer, muiAppEnhancer]; + const enhancers = [muiAppEnhancer]; // Enhance Next page renderer so it also applies MUI and Styled Components stylesheets collectors const originalRenderPage = ctx.renderPage; diff --git a/src/pages/vns/debug/sc-mui.tsx b/src/pages/vns/debug/emotion-mui.tsx similarity index 70% rename from src/pages/vns/debug/sc-mui.tsx rename to src/pages/vns/debug/emotion-mui.tsx index dcca6410..0b52735e 100644 --- a/src/pages/vns/debug/sc-mui.tsx +++ b/src/pages/vns/debug/emotion-mui.tsx @@ -1,6 +1,6 @@ import React from "react"; import { Box, Typography, Container } from "@material-ui/core"; // Next has tree shaking -import StyledComponentsButton from "~/components/ui/StyledComponentsButton"; +import EmotionButton from "~/components/ui/EmotionButton"; export default function MuiSCPage() { return ( @@ -9,9 +9,9 @@ export default function MuiSCPage() { Material UI and Styled components - + I am an orange styled button - + );