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: storybook setup, chromatic setup and typography stories #3015

Merged
merged 31 commits into from
Jul 6, 2024

Conversation

devilkiller-ag
Copy link
Member

Description
This PR adds Storybook and Chromatic to the AsyncAPI Website for developing a UI kit for the website. Additionally, for testing the setup I have included the stories for the Typography (Headings, and Paragraph).

Here is the published storybook.

Copy link

netlify bot commented Jun 1, 2024

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 50c7ee6
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/668929abe0d3ee000881e761
😎 Deploy Preview https://deploy-preview-3015--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Jun 1, 2024

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 37
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🟠 PWA 56

Lighthouse ran on https://deploy-preview-3015--asyncapi-website.netlify.app/

Copy link
Member

@akshatnema akshatnema left a comment

Choose a reason for hiding this comment

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

Do mention about the storybook setup and how to run storybook locally, in the README file.

package.json Outdated
Comment on lines 24 to 27
"storybook": "storybook dev -p 6006",
"chromatic": "chromatic --exit-zero-on-changes",
"build-storybook": "storybook build"
},
Copy link
Member

Choose a reason for hiding this comment

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

Make the script commands according to the pattern followed, like build:storybook. Follow the same for all the scripts added.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

package.json Outdated
Comment on lines 153 to 157
"eslintConfig": {
"extends": [
"plugin:storybook/recommended"
]
}
Copy link
Member

Choose a reason for hiding this comment

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

Add the eslint config in the eslintrc file only.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -0,0 +1,24 @@
# .github/workflows/chromatic.yml
Copy link
Member

Choose a reason for hiding this comment

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

Have you tested this workflow in your forked repo? If yes, kindly share the workflow run link.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it's working

Copy link
Member

Choose a reason for hiding this comment

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

Can you provide the link when you executed in your forked repo?

Copy link
Member Author

Choose a reason for hiding this comment

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


name: 'Chromatic'

on: push
Copy link
Member

Choose a reason for hiding this comment

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

I think it should be done at the PR level. So, you should run this workflow as per pull_request_target.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay Sure

with:
node-version: 20
- name: Install dependencies
run: npm ci
Copy link
Member

Choose a reason for hiding this comment

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

I think installing the dependencies require npm i command.

Copy link
Member Author

Choose a reason for hiding this comment

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

Rectified this

.github/workflows/chromatic.yml Outdated Show resolved Hide resolved
name: "@storybook/nextjs",
options: {},
},
staticDirs: ["..\\public"],
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we provide directory name as ../public for all users?

Copy link
Member Author

Choose a reason for hiding this comment

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

Rectified this

Comment on lines 5 to 11
<style>
body {
font-family: 'Work Sans', sans-serif;
font-optical-sizing: auto;
font-style: normal;
}
</style>
Copy link
Member

Choose a reason for hiding this comment

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

Better to have preview.css file in this folder and import the CSS file here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@akshatnema
Copy link
Member

image

Got this error while trying to initiate the storybook locally. Do correct the relative path, so that it runs for all OS.

@devilkiller-ag
Copy link
Member Author

Got this error while trying to initiate the storybook locally. Do correct the relative path, so that it runs for all OS.

Rectified this.

@akshatnema
Copy link
Member

I can't understand this point. Can you please explain a bit more? We aren't using any extra styling in the storybook. All the styles that we see are the same as defined in the component. We just render the component as it is in the storybook without modifying anything.

If you look into the console inside storybook preview, they aren't any Tailwind styles applied to it. Why it is not able to get Tailwind classes properties?

@akshatnema
Copy link
Member

But, for this storybook needs the variable's description above each variable defined in the prop type interface instead of the current format[which is: variable description is defined in the JSDoc of function.]

@devilkiller-ag Can you please demonstrate this in Heading stories component, so that we are aware about it, how to resolve it.

@akshatnema akshatnema added the gsoc This label should be used for issues or discussions related to ideas for Google Summer of Code label Jun 10, 2024
@devilkiller-ag
Copy link
Member Author

devilkiller-ag commented Jun 10, 2024

@devilkiller-ag Can you please demonstrate this in Heading stories component, so that we are aware about it, how to resolve it.

Done. We will also have to disable eslint lines-around-comment as currently it's displaying an error: Expected line before comment. for JSDoc comments above each interface property.

Here is how it looks after update (Notice the change in description of all props in the table and the description of Heading page):
image

Here is how it looked before:
image

@@ -107,8 +110,17 @@
"yaml": "^2.3.4"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.5.0",
Copy link
Member

Choose a reason for hiding this comment

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

Remove chromatic library for now. We will look into it's use case after further discussions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

package.json Outdated
"generate:tools": "node scripts/build-tools.js"
"generate:tools": "node scripts/build-tools.js",
"dev:storybook": "storybook dev -p 6006",
"chromatic": "chromatic --exit-zero-on-changes",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"chromatic": "chromatic --exit-zero-on-changes",

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Comment on lines 18 to 20
* @param {string} props.textColor contains text color for the paragraph. 'text-gray-700' is by default
* @param {string} props.fontWeight contains class name for applying font weight in the paragraph
* @param {string} props.className contains additional classes that should be added to the component
Copy link
Member

Choose a reason for hiding this comment

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

Add these comments as part of interface comments only.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

Remove this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

.storybook/main.ts Outdated Show resolved Hide resolved

type Story = StoryObj<typeof Paragraph>;

export const Paragraphs: Story = {
Copy link
Member

Choose a reason for hiding this comment

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

Are we using these objects/functions anywhere else? If not, then why are we exporting it?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, we aren't using it manually. But storybook needs to have stories exported (Resource 1 | Resource 2). If we don't have stories exported they won't show up in the storybook.

@@ -0,0 +1,41 @@
import type { Meta, StoryObj } from '@storybook/react';
Copy link
Member

Choose a reason for hiding this comment

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

Why there are no warnings for ESLint in these files for adding Jsdoc comments?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't get this point, I haven't added any JSDoc in this file.

@akshatnema
Copy link
Member

/rtm

@asyncapi-bot asyncapi-bot merged commit 3267eda into asyncapi:master Jul 6, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gsoc This label should be used for issues or discussions related to ideas for Google Summer of Code ready-to-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants