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

🚧 THE 6TH EDITION: Phase 1 #1852

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
133cb0d
feat: add base button components
shawnrivers Aug 9, 2021
bb2f726
build: add layout component in Storybook to switch theme
shawnrivers Aug 9, 2021
d7a6d76
style: refine button styles
shawnrivers Aug 9, 2021
b813c51
refactor: use styles generation functions
shawnrivers Aug 9, 2021
da65917
refactor: add a prop to control border visibility of button component
shawnrivers Aug 9, 2021
45e9850
refactor: add a prop to control background transition visibility of b…
shawnrivers Aug 9, 2021
9f9c7e9
refactor: add active prop of button component
shawnrivers Aug 9, 2021
7c61b86
build: add Headless UI
shawnrivers Aug 9, 2021
aca5c92
feat: add setting menu component
shawnrivers Aug 9, 2021
ba25ba0
refactor: refine codes
shawnrivers Aug 9, 2021
2d58134
feat: modify typographic scaling
shawnrivers Aug 9, 2021
9c21f03
style: remove exiting animation
shawnrivers Aug 11, 2021
f14b7d7
feat: add the album cell component
shawnrivers Aug 11, 2021
03e5c43
feat: add the member cell component
shawnrivers Aug 11, 2021
ac2e376
style: remove default focus styles on buttons
shawnrivers Aug 11, 2021
8a79dc4
style: refine album cell hover animation
shawnrivers Aug 11, 2021
d01844d
refactor: extract a common cover image component
shawnrivers Aug 11, 2021
5c2873a
style: apply cover image styles to the member cell component
shawnrivers Aug 11, 2021
6a34135
feat: add support for not-link member cell
shawnrivers Aug 11, 2021
83878a4
refactor: move album cell to shared
shawnrivers Aug 11, 2021
ab2241b
feat: add song cell and refine other cells
shawnrivers Aug 12, 2021
379fd1b
feat: use MemberCell in the members page
shawnrivers Oct 10, 2021
8d6e012
feat: use AlbumCell in the discography page
shawnrivers Oct 10, 2021
b7ce521
feat: renew album page
shawnrivers Oct 10, 2021
e20dce4
feat: renew member page
shawnrivers Oct 10, 2021
3d80a44
feat: renew song page
shawnrivers Oct 10, 2021
0d44e90
feat: renew search page
shawnrivers Oct 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = {
'no-console': 'warn',
'prefer-const': 'off',
'@next/next/no-img-element': 'off',
'jsx-a11y/anchor-is-valid': 'off',
},
settings: {
react: {
Expand Down
56 changes: 41 additions & 15 deletions .storybook/libs/ThemeDecorator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,60 @@ import { css } from '@emotion/core';
import { EmotionThemeProvider } from 'client/store/emotion/provider';
import { ThemeContextProvider } from 'client/store/theme/context';
import { useThemeContext } from 'client/store/theme/hook/useThemeContext';
import { ThemeMode } from 'client/types/themeMode';
import { Typography } from 'client/components/atoms/Typography';

type ThemeConsumerProps = {
theme?: ThemeMode;
};

const ThemeConsumer: React.FC<ThemeConsumerProps> = props => {
const { theme = 'light' } = props;
const ThemeConsumer: React.FC = () => {
const { themeMode, setTheme } = useThemeContext();

const { setTheme } = useThemeContext();
React.useEffect(() => {
setTheme(theme);
}, [setTheme, theme]);
const handleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
const value = event.target.value;
if (value === 'light' || value === 'dark') {
setTheme(value);
}
};

return null;
return (
<div>
<label
css={css`
display: inline-flex;
align-items: center;
`}
>
<Typography
variant="body2"
element="span"
css={css`
margin-right: 0.5rem;
`}
>
Color Theme:
</Typography>
<select value={themeMode} onChange={handleChange}>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label>
</div>
);
};

export const ThemeDecorator = (options?: Partial<ThemeConsumerProps>) => {
export const ThemeDecorator = () => {
return (Story: any) => {
return (
<ThemeContextProvider>
<EmotionThemeProvider>
<ThemeConsumer />
<hr
css={css`
margin-top: 1.5rem;
`}
/>
<div
css={css`
padding: 24px;
margin-top: 1.5rem;
`}
>
<ThemeConsumer theme={options?.theme} />
<Story />
</div>
</EmotionThemeProvider>
Expand Down
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"dependencies": {
"@emotion/react": "^11.4.1",
"@fontsource/playfair-display": "^4.5.0",
"@headlessui/react": "^1.4.0",
"flexsearch": "^0.6.32",
"focus-visible": "^5.2.0",
"framer-motion": "^4.1.17",
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/atoms/Card/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meta, Story } from '@storybook/react/types-6-0';
import type { Meta, Story } from '@storybook/react';
import { Card, CardProps } from '.';
import { ThemeDecorator } from 'storybook/ThemeDecorator';
import { Typography } from 'client/components/atoms/Typography';
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/atoms/Hashtag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Hashtag: React.FC<HashtagProps> = props => {
element="span"
textColor={textColor}
css={css`
border-radius: ${commonStyles.borderRadius.xl};
border-radius: ${commonStyles.borderRadius.xxs};
border: 1px solid
var(${getColorVarName(textColor.on, textColor.variant)});
padding: ${commonStyles.spacing.xxs} ${commonStyles.spacing[spacing]};
Expand Down
2 changes: 2 additions & 0 deletions src/client/components/atoms/Typography/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const variantMapping: Record<TypographyKey, React.ElementType> = {
h5: 'h5',
h6: 'h6',
h7: 'h6',
h8: 'h6',
body1: 'p',
body2: 'p',
body3: 'p',
Expand All @@ -45,6 +46,7 @@ const defaultFontFamilyMapping: Record<TypographyKey, FontFamily> = {
h5: 'serif',
h6: 'serif',
h7: 'serif',
h8: 'serif',
body1: 'sans',
body2: 'sans',
body3: 'sans',
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/atoms/icons/RadioCheckIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const RadioCheckIcon: React.FC<RadioCheckIconProps> = props => {
`}
{...svgProps}
>
<title>{title}</title>
{title && <title>{title}</title>}
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" />
<circle
Expand Down
166 changes: 86 additions & 80 deletions src/client/components/pages/search/SearchResultCategory/index.tsx
Original file line number Diff line number Diff line change
@@ -1,107 +1,113 @@
import { css } from '@emotion/core';
import * as React from 'react';
import {
Typography,
TypographyProps,
} from 'client/components/atoms/Typography';
import { TypographyProps } from 'client/components/atoms/Typography';
import { commonStyles } from 'client/styles/tokens';
import { useTranslations } from 'client/i18n/hooks/useTranslations';
import {
HorizontalCard,
HorizontalCardProps,
} from 'client/components/molecules/cards/HorizontalCard';
import { HorizontalCardProps } from 'client/components/molecules/cards/HorizontalCard';
import { MemberCell } from 'client/components/v6/shared/cells/MemberCell';
import { AlbumCell } from 'client/components/v6/shared/cells/AlbumCell';
import { SongCell } from 'client/components/v6/shared/cells/SongCell';
import { capitalizeText } from 'utils/string';
import { TextDivider } from 'client/components/molecules/TextDivider';

const DEFAULT_RESULT_COUNT = 4;
type SearchResult = {
href: string;
image: HorizontalCardProps['image'];
heading: HorizontalCardProps['title'];
captions: HorizontalCardProps['tags'];
};

type ResultType = 'members' | 'cds' | 'songs';

const SearchResultCell: React.FC<
SearchResult & {
type: ResultType;
}
> = props => {
if (props.type === 'members') {
return (
<div
css={css`
width: 120px;
height: 170px;
`}
>
<MemberCell
href={props.href}
name={capitalizeText(props.heading.text)}
nameLang={props.heading.lang ?? 'ja'}
caption={props.captions[0].text}
image={props.image}
/>
</div>
);
}
if (props.type === 'cds') {
return (
<div
css={css`
width: 195px;
height: 160px;
`}
>
<AlbumCell
href={props.href}
title={props.heading.text}
caption={props.captions[0].text}
image={props.image}
/>
</div>
);
}
return (
<div
css={css`
width: 180px;
height: 190px;
`}
>
<SongCell
href={props.href}
title={props.heading.text}
titleLang={props.heading.lang ?? 'ja'}
caption={props.captions[0].text}
image={props.image}
/>
</div>
);
};

export type SearchResultCategoryProps = {
title: 'members' | 'cds' | 'songs';
title: ResultType;
titleElement?: TypographyProps['element'];
results: {
href: string;
image: HorizontalCardProps['image'];
heading: HorizontalCardProps['title'];
captions: HorizontalCardProps['tags'];
}[];
results: SearchResult[];
};

export const SearchResultCategory: React.FC<SearchResultCategoryProps> =
props => {
const { title, results, titleElement = 'h3', ...restProps } = props;
const { Translation } = useTranslations();
const [showMore, toggleShowMore] = React.useState(false);
const { getTranslation } = useTranslations();

return results.length > 0 ? (
<section {...restProps}>
<Typography
variant="h6"
element={titleElement}
css={css`
text-transform: capitalize;
`}
>
<Translation text={title} />
</Typography>
<TextDivider text={getTranslation(title)} element={titleElement} />
<ul
css={css`
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
grid-template-rows: auto;
grid-gap: ${commonStyles.spacing.m};
display: flex;
justify-content: center;
flex-wrap: wrap;
margin-top: 1rem;

& > li {
margin: ${commonStyles.spacing.xs};
}
`}
>
{results.slice(0, DEFAULT_RESULT_COUNT).map(result => (
{results.map(result => (
<li key={result.heading.text}>
<HorizontalCard
href={result.href}
image={result.image}
title={result.heading}
titleElement="h3"
tags={result.captions}
capitalizeTitle={title === 'members'}
/>
<SearchResultCell type={title} {...result} />
</li>
))}
{showMore
? results
.slice(DEFAULT_RESULT_COUNT, results.length)
.map(result => (
<li key={result.heading.text}>
<HorizontalCard
href={result.href}
image={result.image}
title={result.heading}
titleElement="h3"
tags={result.captions}
capitalizeTitle={title === 'members'}
/>
</li>
))
: null}
{results.length > DEFAULT_RESULT_COUNT && !showMore ? (
<Typography
variant="body2"
element="button"
textColor={{
on: 'onBackground',
variant: 'variant1',
}}
onClick={() => toggleShowMore(true)}
css={css`
text-transform: uppercase;
align-self: center;
justify-self: start;

@media (hover: hover) and (pointer: fine) {
&:hover {
text-decoration: underline;
}
}
`}
>
<Translation text={'show all'} />
</Typography>
) : null}
</ul>
</section>
) : null;
Expand Down
Loading