Skip to content

Commit

Permalink
Merge pull request #94 from AlecsMissangu/telfe-228-user-profile
Browse files Browse the repository at this point in the history
TELFE 228: User profile
  • Loading branch information
ACoolmanTelicent authored Aug 30, 2024
2 parents 4b2c3af + d33553f commit ec66086
Show file tree
Hide file tree
Showing 20 changed files with 887 additions and 2,493 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ upload.env
main.tsx
App.tsx
.idea

*storybook.log
14 changes: 0 additions & 14 deletions .storybook/DocsContainer.tsx

This file was deleted.

8 changes: 0 additions & 8 deletions .storybook/ThemeWrapper.tsx

This file was deleted.

45 changes: 12 additions & 33 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,17 @@
import type { StorybookConfig } from "@storybook/react-vite";
import remarkGfm from "remark-gfm";

const stories = [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)",
];
const addons = [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-a11y",
"storybook-addon-themes",
// "storybook-dark-mode",
{
name: "@storybook/addon-docs",
options: {
mdxPluginOptions: {
mdxCompileOptions: {
remarkPlugins: [remarkGfm],
},
},
},
},
];
const features = {
storyStoreV7: true,
};
const docs = {
autodocs: true,
};
const config: StorybookConfig = {
stories,
addons,
docs,
features,
framework: "@storybook/react-vite",
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-onboarding",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-vite",
options: {},
},
};
export default config;
13 changes: 0 additions & 13 deletions .storybook/manager.ts

This file was deleted.

1 change: 0 additions & 1 deletion .storybook/preview-body.html

This file was deleted.

50 changes: 16 additions & 34 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
import { Parameters, Preview } from "@storybook/react";
import { themes } from "@storybook/theming";
import React from "react";
import TeliStyledEngineProvider from "../src/providers/TeliStyledEngineProvider/TeliStyledEngineProvider";
import { DocsContainer } from "./DocsContainer";
import ThemeWrapper from "./ThemeWrapper";
import "../src/main.css";
import "../src/assets/fonts/fontawesome/css/all.min.css";
import type { Preview } from "@storybook/react";
import UIThemeProvider from "../src/v1/theme/UIThemeProvider";

const decorators = [
(Story) => <TeliStyledEngineProvider>{Story()}</TeliStyledEngineProvider>,
(Story) => <ThemeWrapper>{Story()}</ThemeWrapper>,
];

const parameters: Parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i, // Doesn't work. I think its a bug in storybook 7 - Alecs
date: /Date$/,
const preview: Preview = {
decorators: [
(Story) => (
<UIThemeProvider theme="DataNavy">
<Story />
</UIThemeProvider>
),
],
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
darkMode: {
classTarget: "html",
stylePreview: true,
dark: { ...themes.dark, appBg: "#1D1D1D", appContentBg: "#1D1D1D" },
light: { ...themes.light, appBg: "#F2F2F2", appContentBg: "#F2F2F2" },
},
a11y: {
element: "#storybook-root",
manual: false,
},
docs: { container: DocsContainer },
};

const preview: Preview = {
decorators,
parameters,
};

export default preview;
34 changes: 18 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"preview": "vite preview",
"test": "react-scripts test",
"eject": "react-scripts eject",
"storybook": "yarn prestart && storybook dev -p 6006",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"storybook-docs": "storybook dev --docs --no-manager-cache",
"build-storybook-docs": "storybook build --docs",
Expand Down Expand Up @@ -74,17 +74,20 @@
},
"devDependencies": {
"@babel/core": "^7.20.12",
"@chromatic-com/storybook": "^1.7.0",
"@commitlint/cli": "17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@storybook/addon-a11y": "^7.6.7",
"@storybook/addon-actions": "^7.6.7",
"@storybook/addon-docs": "^7.6.7",
"@storybook/addon-essentials": "7.6.7",
"@storybook/addon-links": "^7.6.7",
"@storybook/blocks": "^7.6.7",
"@storybook/react": "^7.6.7",
"@storybook/react-vite": "^7.6.7",
"@storybook/test": "^8.1.2",
"@storybook/addon-a11y": "^8.2.9",
"@storybook/addon-actions": "^8.2.9",
"@storybook/addon-docs": "^8.2.9",
"@storybook/addon-essentials": "^8.2.9",
"@storybook/addon-interactions": "^8.2.9",
"@storybook/addon-links": "^8.2.9",
"@storybook/addon-onboarding": "^8.2.9",
"@storybook/blocks": "^8.2.9",
"@storybook/react": "^8.2.9",
"@storybook/react-vite": "^8.2.9",
"@storybook/test": "^8.2.9",
"@testing-library/dom": "^9.2.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
Expand Down Expand Up @@ -118,7 +121,7 @@
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-storybook": "^0.6.15",
"eslint-plugin-storybook": "^0.8.0",
"eslint-plugin-testing-library": "^6.0.0",
"husky": "^8.0.3",
"postcss": "^8.4.29",
Expand All @@ -131,15 +134,14 @@
"remark-gfm": "^3.0.1",
"rollup": "^4.5.0",
"rollup-plugin-copy": "^3.5.0",
"storybook": "7.6.7",
"storybook-addon-themes": "^6.1.0",
"storybook-dark-mode": "^3.0.3",
"storybook": "^8.2.9",
"storybook-dark-mode": "^4.0.2",
"tailwindcss": "^3.4.1",
"typescript": "5.5.4",
"typescript-plugin-css-modules": "^5.0.1",
"vite": "^5.0.2",
"vite-plugin-dts": "^3.6.3",
"vite-plugin-watch-and-run": "1.7.0",
"typescript": "5.5.4"
"vite-plugin-watch-and-run": "1.7.0"
},
"publishConfig": {
"registry": "https://www.npmjs.com/"
Expand Down
File renamed without changes.
7 changes: 1 addition & 6 deletions src/main.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
! tailwindcss v3.4.3 | MIT License | https://tailwindcss.com
! tailwindcss v3.4.10 | MIT License | https://tailwindcss.com
*/

/*
Expand Down Expand Up @@ -12209,7 +12209,6 @@ html {
}

.sticky {
position: -webkit-sticky;
position: sticky;
}

Expand Down Expand Up @@ -12429,10 +12428,6 @@ html {
gap: 1rem;
}

.gap-x-1 {
column-gap: 0.25rem;
}

.gap-x-1\.5 {
column-gap: 0.375rem;
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions src/v1/components/data-display/UserProfile/UserProfile.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { Meta, StoryObj } from "@storybook/react";
import UserProfile from "./UserProfile";
import FlexBox from "../../layout/FlexBox";
import { Text } from "../Text/Text";
import * as UserProfileContentStories from "./UserProfileContent/UserProfileContent.stories";
import UserProfileContent from "./UserProfileContent/UserProfileContent";

const meta = {
component: UserProfile,
tags: ["autodocs"],
// subcomponents: { UserProfileContent }, // doesn't work yet -> https://github.com/storybookjs/storybook/issues/27535
argTypes: {
fullName: {
description: "The user's full name",
},
children: {
control: false,
description: "Content inside the component",
table: {
type: { summary: "ReactNode" },
},
},
},
} satisfies Meta<typeof UserProfile>;

export default meta;
export type Story = StoryObj<typeof meta>;

export const Basic: Story = {
args: {
fullName: "Satoru Gojo",
children: (
<UserProfileContent>
{UserProfileContentStories.WithActions.args?.children}
</UserProfileContent>
),
},
};
2 changes: 1 addition & 1 deletion src/v1/components/data-display/UserProfile/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const UserProfile: React.FC<UserProfileProps> = ({ fullName, children }) => {
slotProps={{
paper: {
sx: {
padding: 3,
padding: 2.5,
border: `1px solid #8D99E270`,
width: 300,
filter: "drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.15))",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import UserProfileContent from "./UserProfileContent";
import FlexBox from "../../../layout/FlexBox";
import { Text } from "../../Text/Text";
import Button from "../../../inputs/Button/Button";

const meta = {
component: UserProfileContent,
tags: ["autodocs"],
decorators: (Story) => (
<div style={{ width: 300 }}>
<Story />
</div>
),
argTypes: {
children: {
control: false,
description: "Content inside the component",
table: {
type: { summary: "ReactNode" },
},
},
},
} satisfies Meta<typeof UserProfileContent>;

export default meta;
export type Story = StoryObj<typeof meta>;

const items = [
{ heading: "Username", value: "Admin" },
{ heading: "Email", value: "admin@telicent.io" },
{ heading: "Deployed Organisation", value: "Telicent" },
{ heading: "UserId", value: "3004958Ed-23-sdf-404-21334" },
{ heading: "Attributes", value: "GBR" },
{ heading: "Clearance", value: "SEN" },
];

export const Basic: Story = {
args: {
children: items.slice(0, 3).map((item) => (
<FlexBox key={item.heading}>
<Text>
<b>{item.heading}</b>
</Text>
<Text>{item.value}</Text>
</FlexBox>
)),
},
};

export const WithActions: Story = {
args: {
children: (
<>
{items.map((item) => (
<FlexBox key={item.heading}>
<Text>
<b>{item.heading}</b>
</Text>
<Text>{item.value}</Text>
</FlexBox>
))}
<FlexBox direction="row" columnGap={2} justifyContent="end">
<Button variant="secondary" disableElevation>
Action
</Button>
<Button disableElevation>Action</Button>
</FlexBox>
</>
),
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { PropsWithChildren } from "react";
import MUIAvatar from "@mui/material/Avatar";
import MUIStack from "@mui/material/Stack";

import { H2 } from "../../Text/Text";
import UserIcon from "../../Icons/UserIcon";

const UserProfileContent: React.FC<PropsWithChildren> = ({ children }) => (
<MUIStack rowGap={2}>
<MUIStack direction="row" columnGap={1} alignItems="center">
<MUIAvatar variant="circular-outlined" sx={{ width: 32, height: 32 }}>
<UserIcon color="primary" />
</MUIAvatar>
<H2 variant="h4">User Profile</H2>
</MUIStack>
{children}
</MUIStack>
);

export default UserProfileContent;
Loading

0 comments on commit ec66086

Please # to comment.