preview.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import { TooltipProvider } from "@radix-ui/react-tooltip";
  2. import { themes } from "@storybook/theming";
  3. import I18nProvider from "next-translate/I18nProvider";
  4. import "../src/styles/fonts.scss";
  5. import "../src/styles/global.scss";
  6. import "../src/styles/reset.scss";
  7. import "../src/styles/theme.scss";
  8. import "./styles.scss";
  9. import commonEn from "../locales/en/common.json";
  10. import homeEn from "../locales/en/home.json";
  11. const themeDecorator = (Story, context) => {
  12. const theme = context.globals.theme;
  13. return (
  14. <>
  15. <div data-theme={theme}>
  16. <div
  17. style={{
  18. backgroundColor: "var(--color-background-default)",
  19. width: "100vw",
  20. height: "100vh",
  21. padding: "1rem",
  22. boxSizing: "border-box",
  23. }}
  24. >
  25. <TooltipProvider>
  26. <I18nProvider
  27. lang="en"
  28. namespaces={{ common: commonEn, home: homeEn }}
  29. >
  30. <Story />
  31. </I18nProvider>
  32. </TooltipProvider>
  33. </div>
  34. </div>
  35. </>
  36. );
  37. };
  38. export const decorators = [themeDecorator];
  39. export const globalTypes = {
  40. theme: {
  41. name: "Theme",
  42. description: "Global theme for components",
  43. defaultValue: "light",
  44. toolbar: {
  45. icon: "circlehollow",
  46. items: ["light", "dark", "sepia"],
  47. showName: true,
  48. },
  49. },
  50. };
  51. const viewports = {
  52. mobileS: {
  53. name: "MobileS",
  54. styles: {
  55. width: `320px`,
  56. height: "100%",
  57. },
  58. },
  59. mobileM: {
  60. name: "MobileM",
  61. styles: {
  62. width: `375px`,
  63. height: "100%",
  64. },
  65. },
  66. mobileL: {
  67. name: "MobileL",
  68. styles: {
  69. width: `425px`,
  70. height: "100%",
  71. },
  72. },
  73. tablet: {
  74. name: "Tablet",
  75. styles: {
  76. width: `768px`,
  77. height: "100%",
  78. },
  79. },
  80. desktop: {
  81. name: "Desktop",
  82. styles: {
  83. width: `1024px`,
  84. height: "100%",
  85. },
  86. },
  87. };
  88. export const parameters = {
  89. layout: "fullscreen",
  90. viewport: {
  91. viewports,
  92. },
  93. docs: {
  94. theme: themes.dark,
  95. },
  96. };