mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
refactor: clean up Welcome component (#11526)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { Welcome } from "./Welcome";
|
||||
|
||||
const meta: Meta<typeof Welcome> = {
|
||||
title: "components/Welcome",
|
||||
component: Welcome,
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Welcome>;
|
||||
|
||||
const Example: Story = {};
|
||||
|
||||
export { Example as Welcome };
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type Interpolation, type Theme } from "@emotion/react";
|
||||
import { type FC, type PropsWithChildren } from "react";
|
||||
import { useTheme } from "@emotion/react";
|
||||
import { CoderIcon } from "../Icons/CoderIcon";
|
||||
|
||||
const Language = {
|
||||
@@ -10,43 +10,39 @@ const Language = {
|
||||
),
|
||||
};
|
||||
|
||||
export const Welcome: FC<
|
||||
PropsWithChildren<{ message?: JSX.Element | string }>
|
||||
> = ({ message = Language.defaultMessage }) => {
|
||||
const theme = useTheme();
|
||||
|
||||
export const Welcome: FC<PropsWithChildren> = ({ children }) => {
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
css={{
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<CoderIcon
|
||||
css={{
|
||||
color: theme.palette.text.primary,
|
||||
fontSize: 64,
|
||||
}}
|
||||
/>
|
||||
<div css={styles.container}>
|
||||
<CoderIcon css={styles.icon} />
|
||||
</div>
|
||||
<h1
|
||||
css={{
|
||||
textAlign: "center",
|
||||
fontSize: 32,
|
||||
fontWeight: 400,
|
||||
margin: 0,
|
||||
marginTop: 16,
|
||||
marginBottom: 32,
|
||||
lineHeight: 1.25,
|
||||
|
||||
"& strong": {
|
||||
fontWeight: 600,
|
||||
},
|
||||
}}
|
||||
>
|
||||
{message}
|
||||
</h1>
|
||||
<h1 css={styles.header}>{children || Language.defaultMessage}</h1>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = {
|
||||
container: {
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
},
|
||||
|
||||
icon: (theme) => ({
|
||||
color: theme.palette.text.primary,
|
||||
fontSize: 64,
|
||||
}),
|
||||
|
||||
header: {
|
||||
textAlign: "center",
|
||||
fontSize: 32,
|
||||
fontWeight: 400,
|
||||
margin: 0,
|
||||
marginTop: 16,
|
||||
marginBottom: 32,
|
||||
lineHeight: 1.25,
|
||||
|
||||
"& strong": {
|
||||
fontWeight: 600,
|
||||
},
|
||||
},
|
||||
} satisfies Record<string, Interpolation<Theme>>;
|
||||
|
||||
@@ -20,7 +20,7 @@ export const CliAuthPageView: FC<CliAuthPageViewProps> = ({ sessionToken }) => {
|
||||
|
||||
return (
|
||||
<SignInLayout>
|
||||
<Welcome message="Session token" />
|
||||
<Welcome>Session token</Welcome>
|
||||
|
||||
<p
|
||||
css={{
|
||||
|
||||
@@ -69,7 +69,8 @@ const ExternalAuthPage: FC = () => {
|
||||
// show an error there?
|
||||
return (
|
||||
<SignInLayout>
|
||||
<Welcome message="Failed to validate oauth access token" />
|
||||
<Welcome>Failed to validate oauth access token</Welcome>
|
||||
|
||||
<p css={{ textAlign: "center" }}>
|
||||
Attempted to validate the user's oauth access token from the
|
||||
authentication flow. This situation may occur as a result of an
|
||||
|
||||
@@ -33,7 +33,7 @@ const ExternalAuthPageView: FC<ExternalAuthPageViewProps> = ({
|
||||
if (!externalAuth.authenticated) {
|
||||
return (
|
||||
<SignInLayout>
|
||||
<Welcome message={`Authenticate with ${externalAuth.display_name}`} />
|
||||
<Welcome>Authenticate with {externalAuth.display_name}</Welcome>
|
||||
|
||||
{externalAuth.device && (
|
||||
<GitDeviceAuth
|
||||
@@ -63,9 +63,10 @@ const ExternalAuthPageView: FC<ExternalAuthPageViewProps> = ({
|
||||
|
||||
return (
|
||||
<SignInLayout>
|
||||
<Welcome
|
||||
message={`You've authenticated with ${externalAuth.display_name}!`}
|
||||
/>
|
||||
<Welcome>
|
||||
You've authenticated with {externalAuth.display_name}!
|
||||
</Welcome>
|
||||
|
||||
<p css={styles.text}>
|
||||
{externalAuth.user?.login && `Hey @${externalAuth.user?.login}! 👋 `}
|
||||
{(!externalAuth.app_installable ||
|
||||
|
||||
Reference in New Issue
Block a user