From c8adad6c817e62bf22522290b26f6bd233b08a65 Mon Sep 17 00:00:00 2001 From: Katalina Okano Date: Sat, 24 Oct 2020 22:18:54 -0400 Subject: [PATCH] feat(design-system): port templates --- .../auth-login/AuthLogin.stories.tsx | 17 +++++++++++++ .../templates/auth-login/AuthLogin.story.tsx | 18 ------------- .../templates/auth-login/AuthLogin.tsx | 5 +--- .../templates/auth-login/BUILD.bazel | 12 +++++++++ .../templates/errors/BUILD.bazel | 14 +++++++++++ .../{Errors.story.tsx => Errors.stories.tsx} | 4 +-- src/design-system/templates/errors/Errors.tsx | 13 ++++++---- .../templates/errors/errorStrings.ts | 6 +---- .../templates/help-page/BUILD.bazel | 12 +++++++++ ...elpPage.story.tsx => HelpPage.stories.tsx} | 9 ++++--- .../templates/help-page/HelpPage.tsx | 4 +-- .../templates/help-page/index.ts | 1 + .../templates/landing/BUILD.bazel | 11 ++++++++ .../templates/landing/Landing.stories.tsx | 8 ++++++ .../templates/landing/Landing.story.tsx | 7 ------ .../templates/role-picker/BUILD.bazel | 12 +++++++++ ...icker.story.tsx => RolePicker.stories.tsx} | 25 ++++++++++++------- .../templates/role-picker/RolePicker.tsx | 10 +++++--- 18 files changed, 128 insertions(+), 60 deletions(-) create mode 100644 src/design-system/templates/auth-login/AuthLogin.stories.tsx delete mode 100644 src/design-system/templates/auth-login/AuthLogin.story.tsx create mode 100644 src/design-system/templates/auth-login/BUILD.bazel create mode 100644 src/design-system/templates/errors/BUILD.bazel rename src/design-system/templates/errors/{Errors.story.tsx => Errors.stories.tsx} (64%) create mode 100644 src/design-system/templates/help-page/BUILD.bazel rename src/design-system/templates/help-page/{HelpPage.story.tsx => HelpPage.stories.tsx} (65%) create mode 100644 src/design-system/templates/help-page/index.ts create mode 100644 src/design-system/templates/landing/BUILD.bazel create mode 100644 src/design-system/templates/landing/Landing.stories.tsx delete mode 100644 src/design-system/templates/landing/Landing.story.tsx create mode 100644 src/design-system/templates/role-picker/BUILD.bazel rename src/design-system/templates/role-picker/{RolePicker.story.tsx => RolePicker.stories.tsx} (63%) diff --git a/src/design-system/templates/auth-login/AuthLogin.stories.tsx b/src/design-system/templates/auth-login/AuthLogin.stories.tsx new file mode 100644 index 0000000..ac439c7 --- /dev/null +++ b/src/design-system/templates/auth-login/AuthLogin.stories.tsx @@ -0,0 +1,17 @@ +import * as React from 'react'; +import { AuthLogin } from './AuthLogin'; +import { guild } from 'roleypoly/src/design-system/shared-types/storyData'; + +export default { + title: 'Templates/Auth: Login', + args: { + botName: 'roleypoly#3266', + }, +}; + +export const NoSlug = (args) => ; + +export const WithSlug = (args) => ; +WithSlug.args = { + guildSlug: guild, +}; diff --git a/src/design-system/templates/auth-login/AuthLogin.story.tsx b/src/design-system/templates/auth-login/AuthLogin.story.tsx deleted file mode 100644 index ff32a9f..0000000 --- a/src/design-system/templates/auth-login/AuthLogin.story.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import * as React from 'react'; -import { templateStories } from 'templates/templates.story'; -import { AuthLogin } from './AuthLogin'; -import { action } from '@storybook/addon-actions'; -import { guild } from 'roleypoly/src/design-system/shared-types/storyData'; - -const story = templateStories('Login', module); - -story.add('No Slug', () => ( - -)); -story.add('With Slug', () => ( - -)); diff --git a/src/design-system/templates/auth-login/AuthLogin.tsx b/src/design-system/templates/auth-login/AuthLogin.tsx index a8298e3..3c8f7a8 100644 --- a/src/design-system/templates/auth-login/AuthLogin.tsx +++ b/src/design-system/templates/auth-login/AuthLogin.tsx @@ -1,9 +1,6 @@ import { Hero } from 'roleypoly/src/design-system/atoms/hero'; import { AppShell } from 'roleypoly/src/design-system/organisms/app-shell'; -import { - Preauth, - PreauthProps, -} from 'roleypoly/src/design-system/organisms/preauth/Preauth'; +import { Preauth, PreauthProps } from 'roleypoly/src/design-system/organisms/preauth'; import * as React from 'react'; export type AuthLoginProps = PreauthProps; diff --git a/src/design-system/templates/auth-login/BUILD.bazel b/src/design-system/templates/auth-login/BUILD.bazel new file mode 100644 index 0000000..a925343 --- /dev/null +++ b/src/design-system/templates/auth-login/BUILD.bazel @@ -0,0 +1,12 @@ +load("//hack/bazel/js:react.bzl", "react_library") + +package(default_visibility = ["//visibility:public"]) + +react_library( + name = "auth-login", + deps = [ + "//src/design-system/atoms/hero", + "//src/design-system/organisms/app-shell", + "//src/design-system/organisms/preauth", + ], +) diff --git a/src/design-system/templates/errors/BUILD.bazel b/src/design-system/templates/errors/BUILD.bazel new file mode 100644 index 0000000..4beba01 --- /dev/null +++ b/src/design-system/templates/errors/BUILD.bazel @@ -0,0 +1,14 @@ +load("//hack/bazel/js:react.bzl", "react_library") + +package(default_visibility = ["//visibility:public"]) + +react_library( + name = "errors", + deps = [ + "//src/design-system/atoms/dot-overlay", + "//src/design-system/atoms/hero", + "//src/design-system/molecules/error-banner", + "//src/design-system/organisms/app-shell", + "//src/design-system/shared-types", + ], +) diff --git a/src/design-system/templates/errors/Errors.story.tsx b/src/design-system/templates/errors/Errors.stories.tsx similarity index 64% rename from src/design-system/templates/errors/Errors.story.tsx rename to src/design-system/templates/errors/Errors.stories.tsx index 8edd547..219c502 100644 --- a/src/design-system/templates/errors/Errors.story.tsx +++ b/src/design-system/templates/errors/Errors.stories.tsx @@ -1,9 +1,9 @@ import * as React from 'react'; -import { templateStories } from 'templates/templates.story'; +import { storiesOf } from '@storybook/react'; import { Error } from './Errors'; import { errorMessages } from './errorStrings'; -const messages = templateStories('Errors/Messages', module); +const messages = storiesOf('Templates/Errors', module); for (let message in errorMessages) { messages.add(`${message}`, () => ); diff --git a/src/design-system/templates/errors/Errors.tsx b/src/design-system/templates/errors/Errors.tsx index d73f821..a3b68f3 100644 --- a/src/design-system/templates/errors/Errors.tsx +++ b/src/design-system/templates/errors/Errors.tsx @@ -1,15 +1,18 @@ +import * as React from 'react'; import { DotOverlay } from 'roleypoly/src/design-system/atoms/dot-overlay'; import { Hero } from 'roleypoly/src/design-system/atoms/hero'; +import { + ErrorBanner, + ErrorMessage, +} from 'roleypoly/src/design-system/molecules/error-banner'; import { AppShell } from 'roleypoly/src/design-system/organisms/app-shell'; -import * as React from 'react'; -import { ErrorMessage, getMessageFromCode } from './errorStrings'; -import { ErrorBanner } from 'roleypoly/src/design-system/organisms/error-banner'; -import { RoleypolyUser } from '@roleypoly/rpc/shared'; +import { RoleypolyUser } from 'roleypoly/src/design-system/shared-types'; +import { getMessageFromCode } from './errorStrings'; export type ErrorProps = { code: string | number; messageOverride?: ErrorMessage; - user?: RoleypolyUser.AsObject | null; + user?: RoleypolyUser | null; }; export const Error = (props: ErrorProps) => { diff --git a/src/design-system/templates/errors/errorStrings.ts b/src/design-system/templates/errors/errorStrings.ts index 57e3b89..060074d 100644 --- a/src/design-system/templates/errors/errorStrings.ts +++ b/src/design-system/templates/errors/errorStrings.ts @@ -1,8 +1,4 @@ -export type ErrorMessage = { - english: string; - japanese?: string; - friendlyCode?: string; -}; +import { ErrorMessage } from 'roleypoly/src/design-system/molecules/error-banner'; const defaultMessage: Required = { english: `Something went bad. How could this happen?`, diff --git a/src/design-system/templates/help-page/BUILD.bazel b/src/design-system/templates/help-page/BUILD.bazel new file mode 100644 index 0000000..a7822d2 --- /dev/null +++ b/src/design-system/templates/help-page/BUILD.bazel @@ -0,0 +1,12 @@ +load("//hack/bazel/js:react.bzl", "react_library") + +package(default_visibility = ["//visibility:public"]) + +react_library( + name = "help-page", + deps = [ + "//src/design-system/molecules/help-page-base", + "//src/design-system/organisms/app-shell", + "//src/design-system/shared-types", + ], +) diff --git a/src/design-system/templates/help-page/HelpPage.story.tsx b/src/design-system/templates/help-page/HelpPage.stories.tsx similarity index 65% rename from src/design-system/templates/help-page/HelpPage.story.tsx rename to src/design-system/templates/help-page/HelpPage.stories.tsx index d69c7fd..69055fc 100644 --- a/src/design-system/templates/help-page/HelpPage.story.tsx +++ b/src/design-system/templates/help-page/HelpPage.stories.tsx @@ -1,12 +1,13 @@ import * as React from 'react'; -import { templateStories } from 'templates/templates.story'; import { HelpPageTemplate } from './HelpPage'; -const story = templateStories('Help Page', module); +export default { + title: 'Templates/Help Page', +}; -story.add('Base', () => ( +export const Base = () => (

What is the world but vibrations?

Vibrations that synchronize and tie it together, running free forever.

-)); +); diff --git a/src/design-system/templates/help-page/HelpPage.tsx b/src/design-system/templates/help-page/HelpPage.tsx index f4d4c49..10a371e 100644 --- a/src/design-system/templates/help-page/HelpPage.tsx +++ b/src/design-system/templates/help-page/HelpPage.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { AppShell } from 'roleypoly/src/design-system/organisms/app-shell'; -import { HelpPageBase } from 'roleypoly/src/design-system/organisms/help-page-base'; -import { RoleypolyUser } from '@roleypoly/rpc/shared'; +import { HelpPageBase } from 'roleypoly/src/design-system/molecules/help-page-base'; +import { RoleypolyUser } from 'roleypoly/src/design-system/shared-types'; type HelpPageProps = { user: RoleypolyUser.AsObject | null; diff --git a/src/design-system/templates/help-page/index.ts b/src/design-system/templates/help-page/index.ts new file mode 100644 index 0000000..7406751 --- /dev/null +++ b/src/design-system/templates/help-page/index.ts @@ -0,0 +1 @@ +export * from './HelpPage'; diff --git a/src/design-system/templates/landing/BUILD.bazel b/src/design-system/templates/landing/BUILD.bazel new file mode 100644 index 0000000..45a41f8 --- /dev/null +++ b/src/design-system/templates/landing/BUILD.bazel @@ -0,0 +1,11 @@ +load("//hack/bazel/js:react.bzl", "react_library") + +package(default_visibility = ["//visibility:public"]) + +react_library( + name = "landing", + deps = [ + "//src/design-system/organisms/app-shell", + "//src/design-system/organisms/landing", + ], +) diff --git a/src/design-system/templates/landing/Landing.stories.tsx b/src/design-system/templates/landing/Landing.stories.tsx new file mode 100644 index 0000000..99e03e4 --- /dev/null +++ b/src/design-system/templates/landing/Landing.stories.tsx @@ -0,0 +1,8 @@ +import * as React from 'react'; +import { LandingTemplate } from './Landing'; + +export default { + title: 'Templates/Landing', +}; + +export const Landing = () => ; diff --git a/src/design-system/templates/landing/Landing.story.tsx b/src/design-system/templates/landing/Landing.story.tsx deleted file mode 100644 index c0e6e98..0000000 --- a/src/design-system/templates/landing/Landing.story.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import * as React from 'react'; -import { templateStories } from 'templates/templates.story'; -import { LandingTemplate } from './Landing'; - -const story = templateStories('Landing', module); - -story.add('Landing', () => ); diff --git a/src/design-system/templates/role-picker/BUILD.bazel b/src/design-system/templates/role-picker/BUILD.bazel new file mode 100644 index 0000000..871212d --- /dev/null +++ b/src/design-system/templates/role-picker/BUILD.bazel @@ -0,0 +1,12 @@ +load("//hack/bazel/js:react.bzl", "react_library") + +package(default_visibility = ["//visibility:public"]) + +react_library( + name = "role-picker", + deps = [ + "//src/design-system/organisms/app-shell", + "//src/design-system/organisms/role-picker", + "//src/design-system/shared-types", + ], +) diff --git a/src/design-system/templates/role-picker/RolePicker.story.tsx b/src/design-system/templates/role-picker/RolePicker.stories.tsx similarity index 63% rename from src/design-system/templates/role-picker/RolePicker.story.tsx rename to src/design-system/templates/role-picker/RolePicker.stories.tsx index f934d31..bdcdbb8 100644 --- a/src/design-system/templates/role-picker/RolePicker.story.tsx +++ b/src/design-system/templates/role-picker/RolePicker.stories.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { templateStories } from 'templates/templates.story'; import { RolePickerTemplate, RolePickerTemplateProps } from './RolePicker'; import { guildData, @@ -9,10 +8,6 @@ import { rpUser, guildEnum, } from 'roleypoly/src/design-system/shared-types/storyData'; -import { action } from '@storybook/addon-actions'; -import { boolean } from '@storybook/addon-knobs'; - -const story = templateStories('Role Picker', module); const props: RolePickerTemplateProps = { guildData: { @@ -23,13 +18,25 @@ const props: RolePickerTemplateProps = { member: member, guild: guild, roles: guildRoles, - onSubmit: action('onSubmit'), editable: false, user: rpUser, guildEnumeration: guildEnum, activeGuildId: guild.id, }; -story.add('Role Picker', () => { - return ; -}); +export default { + title: 'Templates/Role Picker', + components: RolePickerTemplate, + args: props, +}; + +export const Default = (args) => { + return ; +}; + +export const Editable = (args) => { + return ; +}; +Editable.args = { + editable: true, +}; diff --git a/src/design-system/templates/role-picker/RolePicker.tsx b/src/design-system/templates/role-picker/RolePicker.tsx index 8bc39d4..f47d7cc 100644 --- a/src/design-system/templates/role-picker/RolePicker.tsx +++ b/src/design-system/templates/role-picker/RolePicker.tsx @@ -4,12 +4,14 @@ import { RolePicker, RolePickerProps, } from 'roleypoly/src/design-system/organisms/role-picker'; -import { RoleypolyUser } from '@roleypoly/rpc/shared'; -import { GuildEnumeration } from '@roleypoly/rpc/platform'; +import { + GuildEnumeration, + RoleypolyUser, +} from 'roleypoly/src/design-system/shared-types'; export type RolePickerTemplateProps = RolePickerProps & { - user: RoleypolyUser.AsObject; - guildEnumeration?: GuildEnumeration.AsObject; + user: RoleypolyUser; + guildEnumeration?: GuildEnumeration; activeGuildId?: string; };