Skip to content

Commit

Permalink
able to add githubUsername
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Oct 11, 2023
1 parent 5ca7927 commit 07115f3
Show file tree
Hide file tree
Showing 52 changed files with 97 additions and 3 deletions.
1 change: 1 addition & 0 deletions .hygen/_templates/block/new/Component.stories.ejs.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const meta = {
component: <%=h.toName(name)%>,
parameters: {
layout: "centered",
githubUsername: "", // (optional) Your github username. If provided, your avatar will be displayed in the story toolbar
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof <%=h.toName(name)%>>;
Expand Down
34 changes: 34 additions & 0 deletions .storybook/decorators/Author.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { memo } from "react";
import { Img } from "@storybook/components";
import { useParameter } from "@storybook/manager-api";

export const Tool = memo(function MyAddonSelector() {
const author = useParameter<string | undefined>("githubUsername");
if (!author) {
return null;
}
return (
<a
key="contributor"
style={{
display: "flex",
gap: "0.25rem",
alignItems: "center",
alignSelf: "center",
fontSize: "0.75rem",
fontWeight: 600,
color: "#029CFD",
textDecoration: "none",
}}
href={`/~https://github.com/${author}`}
target="_blank"
rel="noopener noreferrer"
>
<Img
src={`/~https://github.com/${author}.png?size=64`}
style={{ width: 28, borderRadius: 28 }}
/>
By {author}
</a>
);
});
14 changes: 12 additions & 2 deletions .storybook/manager.ts → .storybook/manager.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { addons } from "@storybook/addons";
import React from "react";
import ReactGA from "react-ga4";
import { addons, types } from "@storybook/addons";
import {
STORY_CHANGED,
STORY_ERRORED,
STORY_MISSING,
} from "@storybook/core-events";
import ReactGA from "react-ga4";
import { Tool } from "./decorators/Author";

// https://storybook.js.org/docs/react/configure/features-and-behavior
addons.setConfig({
Expand Down Expand Up @@ -41,3 +43,11 @@ addons.register("google-analytics", (api) => {
});
});
});

addons.register("contributor", () => {
addons.add("contributor/toolbar", {
title: "Author",
type: types.TOOL,
render: Tool as unknown as () => React.ReactElement,
});
});
1 change: 1 addition & 0 deletions blocks/card-apple-arcade/src/CardAppleArcade.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardAppleArcade,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardAppleArcade>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardAppleEssentials,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardAppleEssentials>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-apple-video/src/CardAppleVideo.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardAppleVideo,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardAppleVideo>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardCoverInterest,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardCoverInterest>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-cover-stream/src/CardCoverStream.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardCoverStream,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardCoverStream>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-cover-travel/src/CardCoverTravel.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardCoverTravel,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardCoverTravel>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-cover-trip/src/CardCoverTrip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardCoverTrip,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardCoverTrip>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardDashboardCompany,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardDashboardCompany>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const meta = {
component: CardDashboardStat1,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardDashboardStat1>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const meta = {
component: CardDashboardStat2,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardDashboardStat2>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const meta = {
component: CardDashboardStat3,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardDashboardStat3>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const meta = {
component: CardDashboardStat4,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardDashboardStat4>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const meta = {
component: CardDashboardStat5,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardDashboardStat5>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardDashboardStat6,
parameters: {
layout: "padded",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardDashboardStat6>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-featured-city/src/CardFeaturedCity.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardFeaturedCity,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [
storyDialog(Usage),
Expand Down
1 change: 1 addition & 0 deletions blocks/card-featured-repo/src/CardFeaturedRepo.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardFeaturedRepo,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardFeaturedRepo>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-form-signup/src/CardFormSignup.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardFormSignup,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardFormSignup>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-grid-simple/src/CardGridSimple.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardGridSimple,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardGridSimple>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-link-embed/src/CardLinkEmbed.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardLinkEmbed,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardLinkEmbed>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-news-maldives/src/CardNewsMaldives.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const meta = {
component: CardNewsMaldives,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardNewsMaldives>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-news-plane/src/CardNewsPlane.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardNewsPlane,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardNewsPlane>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-preview-cafe/src/CardPreviewCafe.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardPreviewCafe,
parameters: {
layout: "centered",
githubUsername: "kevintruo",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardPreviewCafe>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-preview-cafe2/src/CardPreviewCafe2.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardPreviewCafe2,
parameters: {
layout: "centered",
githubUsername: "kevintruo",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardPreviewCafe2>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-pricing-plan/src/CardPricingPlan.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardPricingPlan,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardPricingPlan>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-pricing-plan2/src/CardPricingPlan2.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const meta = {
},
parameters: {
layout: "centered",
githubUsername: "kevintruo",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardPricingPlan2>;
Expand Down
3 changes: 2 additions & 1 deletion blocks/card-social-reply/src/CardSocialReply.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardSocialReply,
parameters: {
layout: "centered",
githubUsername: "bossthanawat",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardSocialReply>;
Expand All @@ -27,7 +28,7 @@ export const Reply: Story = {
overflow: "auto",
}}
>
<CardSocialReply/>
<CardSocialReply />
</div>
),
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CardSocialSuggestions,
parameters: {
layout: "centered",
githubUsername: "pobch",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CardSocialSuggestions>;
Expand Down
1 change: 1 addition & 0 deletions blocks/card-travel-spa/src/CardTravelSpa.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const meta = {
component: CardTravelSpa,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [
storyDialog(Usage),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CarouselAppleGames,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CarouselAppleGames>;
Expand Down
1 change: 1 addition & 0 deletions blocks/cmdk-joy-default/src/CmdkJoyDefault.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: CmdkJoyDefault,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof CmdkJoyDefault>;
Expand Down
1 change: 1 addition & 0 deletions blocks/input-color-picker/src/InputColorPicker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: InputColorPicker,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof InputColorPicker>;
Expand Down
1 change: 1 addition & 0 deletions blocks/input-file-upload/src/InputFileUpload.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: InputFileUpload,
parameters: {
layout: "centered",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof InputFileUpload>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const meta = {
component: LandingCookiesToolbar,
parameters: {
layout: "fullscreen",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof LandingCookiesToolbar>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: LandingMainBenefit,
parameters: {
layout: "fullscreen",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof LandingMainBenefit>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: LandingMainEvervault,
parameters: {
layout: "fullscreen",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof LandingMainEvervault>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: LayoutCarouselSnap,
parameters: {
layout: "padded",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof LayoutCarouselSnap>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: LayoutDashboardCurve,
parameters: {
layout: "fullscreen",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof LayoutDashboardCurve>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: LayoutDashboardInset,
parameters: {
layout: "fullscreen",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof LayoutDashboardInset>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: LayoutDashboardStarter,
parameters: {
layout: "fullscreen",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof LayoutDashboardStarter>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
component: LayoutGridAutofill,
parameters: {
layout: "padded",
githubUsername: "siriwatknp",
},
decorators: [storyDialog(Usage)],
} satisfies Meta<typeof LayoutGridAutofill>;
Expand Down
Loading

0 comments on commit 07115f3

Please sign in to comment.