Compare commits

..

No commits in common. "f677d0e797a28a7d923a30887d8a4b323d9dc6b9" and "90cef2815193749265675a722bc48d453612df63" have entirely different histories.

9 changed files with 69 additions and 137 deletions

View File

@ -1 +0,0 @@
tailwind.config.ts

View File

@ -15,7 +15,7 @@
"rules": { "rules": {
"react/jsx-props-no-spreading": "off" "react/jsx-props-no-spreading": "off"
} }
} },
], ],
"settings": { "settings": {
"react": { "react": {
@ -58,17 +58,6 @@
"no-promise-executor-return": "off", "no-promise-executor-return": "off",
"@typescript-eslint/no-shadow": "off", "@typescript-eslint/no-shadow": "off",
"react/require-default-props": "off", "react/require-default-props": "off",
"import/order": [
"error",
{
"pathGroups": [
{
"pattern": "@/**",
"group": "external"
}
]
}
],
"no-shadow": "off", "no-shadow": "off",
"prettier/prettier": [ "prettier/prettier": [
"warn", "warn",

View File

@ -87,9 +87,6 @@ const preview = {
light: { ...themes.normal, appBg: 'red' }, light: { ...themes.normal, appBg: 'red' },
}, },
parameters: { parameters: {
nextjs: {
appDirectory: true,
},
controls: { controls: {
matchers: { matchers: {
color: /(background|color)$/i, color: /(background|color)$/i,

View File

@ -1,19 +1,21 @@
import dashboardAppModule from "@/app/[lang]/dashboard/module/dashboard-app-module";
import CreateRandomInvoiceButtonVM from "@/app/[lang]/dashboard/vm/create-random-invoice-button-vm"; import CreateRandomInvoiceButtonVM from "@/app/[lang]/dashboard/vm/create-random-invoice-button-vm";
import Button from "@/app/components/button/button"; import Button from "@/app/components/button/button";
import { DiContext, useDI } from "@/bootstrap/di/di-context"; import { DiContext, useDI } from "@/bootstrap/di/di-context";
import mockedModuleDi from "@/bootstrap/di/mocked-module-di";
import Story from "@/bootstrap/helpers/view/storybook-base-template-type"; import Story from "@/bootstrap/helpers/view/storybook-base-template-type";
import getArgVM from "@/bootstrap/helpers/view/storybook-with-arg-vm"; import getArgVM from "@/bootstrap/helpers/view/storybook-with-arg-vm";
import createInvoiceUsecase from "@/feature/core/invoice/domain/usecase/create-invoice-usecase"; import createInvoiceUsecase from "@/feature/core/invoice/domain/usecase/create-invoice-usecase";
import type { Meta } from "@storybook/react"; import type { Meta } from "@storybook/react";
import { useRef } from "react"; import { useRef } from "react";
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta: Meta = { const meta: Meta = {
title: "general/Button", title: "general/Button",
}; };
export default meta; export default meta;
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const Primary: Story = { export const Primary: Story = {
argTypes: { argTypes: {
"vm.props.isDisable": { "vm.props.isDisable": {
@ -28,38 +30,23 @@ export const Primary: Story = {
"vm.props.isDisable": false, "vm.props.isDisable": false,
}, },
render: (_props, globalData) => { render: (_props, globalData) => {
const vm = getArgVM(globalData.parsedProps.vm); // You can use parsed props to access your vm properties. const vm = getArgVM(globalData.parsedProps.vm)// You can use parsed props to access your vm properties.
return <Button vm={vm} memoizedByVM={false} />; return <Button vm={vm} memoizedByVM={false} />
}, }
}; };
export const WithVM: Story = { export const WithVM: Story = {
decorators: [ decorators: [
(Story) => { (Story) => {
const di = mockedModuleDi([ return <Story />
{ }
token: CreateRandomInvoiceButtonVM,
provider: CreateRandomInvoiceButtonVM,
},
{
token: createInvoiceUsecase.name,
// eslint-disable-next-line @typescript-eslint/no-explicit-any, no-console
provider: (args: any) => console.log("clicked", args),
},
]);
return <Story di={di} />;
},
], ],
render: (_, globalProps) => { render: () => {
function Child() { const Child = () => {
const di = useDI(); const di = useDI();
const vm = useRef(di.resolve(CreateRandomInvoiceButtonVM)); const vm = useRef(di.resolve(CreateRandomInvoiceButtonVM));
return <Button vm={vm.current} memoizedByVM={false} />; return <Button vm={vm.current} memoizedByVM={false} />
} }
return ( return (<DiContext.Provider value={dashboardAppModule()}> <Child /> </ DiContext.Provider>)
<DiContext.Provider value={globalProps.di}> }
<Child /> }
</DiContext.Provider>
);
},
};

View File

@ -34,7 +34,7 @@ body {
--chart-5: 27 87% 67%; --chart-5: 27 87% 67%;
--radius: 0.5rem; --radius: 0.5rem;
} }
:root[class~="dark"] { .dark {
--background: 240 10% 3.9%; --background: 240 10% 3.9%;
--foreground: 0 0% 98%; --foreground: 0 0% 98%;
--card: 240 10% 3.9%; --card: 240 10% 3.9%;

View File

@ -1,33 +0,0 @@
import { container, DependencyContainer } from "tsyringe";
import { InjectionToken } from "tsyringe/dist/typings/providers";
import constructor from "tsyringe/dist/typings/types/constructor";
import { isClass } from "../helpers/global-helpers";
/**
* Provides mocked di for test cases and using instead of real di
* @param providers List of providers
* @returns Mocked di with registered providers
*/
const mockedModuleDi = (
providers: {
token: InjectionToken<unknown>;
provider: unknown | constructor<unknown>;
}[],
): DependencyContainer => {
const di = container.createChildContainer();
providers.forEach((provider) => {
if (isClass(provider.provider)) {
di.register(provider.token, provider.provider);
return;
}
di.register(provider.token, {
useValue: provider.provider,
});
});
return di;
};
export default mockedModuleDi;

View File

@ -1,8 +1 @@
import { constructor } from "tsyringe/dist/typings/types";
export const isServer = typeof window === "undefined"; export const isServer = typeof window === "undefined";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function isClass(fn: any): fn is constructor<unknown> {
return typeof fn === "function" && /^(class|function [A-Z])/.test(fn);
}

View File

@ -11,11 +11,11 @@ export default function useThrottle<T extends () => unknown>(
callback: T, callback: T,
time: number = 2000, time: number = 2000,
) { ) {
const lastRun = useRef<number>(); const lastRun = useRef(Date.now());
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
return function () { return function () {
if (lastRun.current && Date.now() - lastRun.current <= time) return; if (Date.now() - lastRun.current <= time) return;
lastRun.current = Date.now(); lastRun.current = Date.now();
callback(); callback();
}; };

View File

@ -11,53 +11,53 @@ const config: Config = {
theme: { theme: {
extend: { extend: {
colors: { colors: {
background: "hsl(var(--background))", background: 'hsl(var(--background))',
foreground: "hsl(var(--foreground))", foreground: 'hsl(var(--foreground))',
card: { card: {
DEFAULT: "hsl(var(--card))", DEFAULT: 'hsl(var(--card))',
foreground: "hsl(var(--card-foreground))", foreground: 'hsl(var(--card-foreground))'
}, },
popover: { popover: {
DEFAULT: "hsl(var(--popover))", DEFAULT: 'hsl(var(--popover))',
foreground: "hsl(var(--popover-foreground))", foreground: 'hsl(var(--popover-foreground))'
}, },
primary: { primary: {
DEFAULT: "hsl(var(--primary))", DEFAULT: 'hsl(var(--primary))',
foreground: "hsl(var(--primary-foreground))", foreground: 'hsl(var(--primary-foreground))'
}, },
secondary: { secondary: {
DEFAULT: "hsl(var(--secondary))", DEFAULT: 'hsl(var(--secondary))',
foreground: "hsl(var(--secondary-foreground))", foreground: 'hsl(var(--secondary-foreground))'
}, },
muted: { muted: {
DEFAULT: "hsl(var(--muted))", DEFAULT: 'hsl(var(--muted))',
foreground: "hsl(var(--muted-foreground))", foreground: 'hsl(var(--muted-foreground))'
}, },
accent: { accent: {
DEFAULT: "hsl(var(--accent))", DEFAULT: 'hsl(var(--accent))',
foreground: "hsl(var(--accent-foreground))", foreground: 'hsl(var(--accent-foreground))'
}, },
destructive: { destructive: {
DEFAULT: "hsl(var(--destructive))", DEFAULT: 'hsl(var(--destructive))',
foreground: "hsl(var(--destructive-foreground))", foreground: 'hsl(var(--destructive-foreground))'
}, },
border: "hsl(var(--border))", border: 'hsl(var(--border))',
input: "hsl(var(--input))", input: 'hsl(var(--input))',
ring: "hsl(var(--ring))", ring: 'hsl(var(--ring))',
chart: { chart: {
"1": "hsl(var(--chart-1))", '1': 'hsl(var(--chart-1))',
"2": "hsl(var(--chart-2))", '2': 'hsl(var(--chart-2))',
"3": "hsl(var(--chart-3))", '3': 'hsl(var(--chart-3))',
"4": "hsl(var(--chart-4))", '4': 'hsl(var(--chart-4))',
"5": "hsl(var(--chart-5))", '5': 'hsl(var(--chart-5))'
}, }
}, },
borderRadius: { borderRadius: {
lg: "var(--radius)", lg: 'var(--radius)',
md: "calc(var(--radius) - 2px)", md: 'calc(var(--radius) - 2px)',
sm: "calc(var(--radius) - 4px)", sm: 'calc(var(--radius) - 4px)'
}, }
}, }
}, },
plugins: [require("tailwindcss-animate")], plugins: [require("tailwindcss-animate")],
}; };