Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement animated features demo component #4

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 38 additions & 20 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-webpack5-compiler-swc",
"@storybook/addon-onboarding",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
Expand All @@ -29,6 +28,34 @@ const config: StorybookConfig = {
},
}),
webpackFinal: config => {
if (config.module && config.module.rules) {
const { rules } = config.module;

const fileLoaderRule = rules.find(rule => rule?.test && rule.test.test(".svg")) as
| { exclude: RegExp }
| undefined;
if (fileLoaderRule) {
fileLoaderRule.exclude = /\.svg$/;
}

const cssLoaderIndex = rules.findIndex(rule => rule?.test && rule.test.test(".css"));
rules.splice(cssLoaderIndex, 1);
}

const postCssLoader = {
loader: "postcss-loader",
options: {
postcssOptions: {
ident: "postcss",
plugins: [
require("postcss-import"),
require("tailwindcss"),
require("autoprefixer"),
],
},
},
};

return {
...config,
resolve: {
Expand All @@ -43,25 +70,16 @@ const config: StorybookConfig = {
rules: [
...(config.module?.rules as Record<string, any>[]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where can I view these rules? can't find them

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we extend storybook's webpack config with some custom rules. By adding ...config.module.rules we make sure to include original rules, we don't want to throw them away when adding ours.

Docs: https://storybook.js.org/docs/api/main-config-webpack-final

{
test: /\.(sa|sc|c)ss$/,
use: [
"style-loader",
"css-loader",
{
loader: "postcss-loader",
options: {
postcssOptions: {
ident: "postcss",
plugins: [
require("postcss-import"),
require("tailwindcss"),
require("autoprefixer"),
],
},
},
},
"sass-loader",
],
test: /\.(sa|sc)ss$/,
use: ["style-loader", "css-loader", postCssLoader, "sass-loader"],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader", postCssLoader],
},
{
test: /\.svg$/,
use: ["@svgr/webpack"],
},
],
},
Expand Down
6 changes: 6 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Jost:ital,wght@0,100..900;1,100..900&family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"
rel="stylesheet"
/>
2 changes: 1 addition & 1 deletion .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Preview } from "@storybook/react";

import "../src/scss/custom.scss";
import "../src/scss/custom.css";

const preview: Preview = {
parameters: {
Expand Down
12 changes: 10 additions & 2 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ const config: Config = {
defaultLocale: "en",
locales: ["en"],
},

headTags: [
{
tagName: "link",
attributes: {
href: "https://fonts.googleapis.com/css2?family=Jost:ital,wght@0,100..900;1,100..900&family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap",
rel: "stylesheet",
},
},
],
presets: [
[
"classic",
Expand All @@ -39,7 +47,7 @@ const config: Config = {
editUrl: "https://github.com/gemini-testing/testplane-docs/tree/main/blog/",
},
theme: {
customCss: "./src/scss/custom.scss",
customCss: "./src/scss/custom.css",
},
} satisfies Preset.Options,
],
Expand Down
7 changes: 6 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import geminiTesting from "eslint-config-gemini-testing";
import reactRecommended from "eslint-plugin-react/configs/recommended.js";
import reactJsxRuntime from "eslint-plugin-react/configs/jsx-runtime.js";
import prettier from "eslint-config-prettier";
import _ from "lodash";
import tseslint from "typescript-eslint";

export default tseslint.config(
Expand Down Expand Up @@ -47,7 +48,11 @@ export default tseslint.config(
reactRecommended,
reactJsxRuntime,
{
rules: geminiTesting.rules,
rules: _.omit(geminiTesting.rules, [
// Rules that conflict with typescript-eslint.
"no-undef",
"no-unused-vars",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to exclude this rule?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it conflicts with typescript-eslint, as stated in the comment above. It provides its own rule, @typescript-eslint/no-unusd-vars, because the original one doesn't work well with TS code.

]),
},
prettier,
);
Loading
Loading