-
Notifications
You must be signed in to change notification settings - Fork 813
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flat-components): add home page hero button (#418)
- Loading branch information
Showing
9 changed files
with
302 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
packages/flat-components/src/assets/buttons/create-small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
packages/flat-components/src/assets/buttons/join-small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
packages/flat-components/src/assets/buttons/schedule-small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions
53
packages/flat-components/src/components/HomePageHeroButton/HomePageHeroButton.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Meta, Story } from "@storybook/react"; | ||
import { MINIMAL_VIEWPORTS } from "@storybook/addon-viewport"; | ||
import React from "react"; | ||
import { HomePageHeroButtons, HomePageHeroButtonsProps } from "."; | ||
|
||
const storyMeta: Meta = { | ||
title: "Components/HomePageHeroButtons", | ||
component: HomePageHeroButtons, | ||
parameters: { | ||
backgrounds: { | ||
default: "flat", | ||
values: [ | ||
{ | ||
name: "flat", | ||
value: "#F3F6F9", | ||
}, | ||
], | ||
}, | ||
viewport: { | ||
viewports: { | ||
...MINIMAL_VIEWPORTS, | ||
tablet2: { | ||
name: "Large Tablet", | ||
styles: { width: "659px", height: "1000px" }, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default storyMeta; | ||
|
||
export const Overview: Story<HomePageHeroButtonsProps> = args => ( | ||
<HomePageHeroButtons {...args} /> | ||
); | ||
|
||
export const TabletScreen: Story<HomePageHeroButtonsProps> = args => ( | ||
<HomePageHeroButtons {...args} /> | ||
); | ||
TabletScreen.parameters = { | ||
viewport: { | ||
defaultViewport: "tablet2", | ||
}, | ||
}; | ||
|
||
export const SmallScreen: Story<HomePageHeroButtonsProps> = args => ( | ||
<HomePageHeroButtons {...args} /> | ||
); | ||
SmallScreen.parameters = { | ||
viewport: { | ||
defaultViewport: "mobile1", | ||
}, | ||
}; |
77 changes: 77 additions & 0 deletions
77
packages/flat-components/src/components/HomePageHeroButton/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import "./style.less"; | ||
import React from "react"; | ||
import classNames from "classnames"; | ||
import { Button } from "antd"; | ||
|
||
type HomePageHeroButtonType = "join" | "create" | "schedule"; | ||
|
||
interface HomePageHeroButtonBaseProps { | ||
type: HomePageHeroButtonType; | ||
longText: string; | ||
shortText: string; | ||
onClick?: () => void; | ||
} | ||
|
||
const HomePageHeroButtonBase: React.FC<HomePageHeroButtonBaseProps> = ({ | ||
type, | ||
longText, | ||
shortText, | ||
onClick, | ||
}) => { | ||
return ( | ||
<Button | ||
className="home-page-hero-button" | ||
onClick={onClick}> | ||
<span className={classNames("icon", type)}></span> | ||
<span className="text long">{longText}</span> | ||
<span className="text short">{shortText}</span> | ||
</Button> | ||
); | ||
}; | ||
|
||
export interface HomePageHeroButtonProps { | ||
type: HomePageHeroButtonType; | ||
onClick?: () => void; | ||
} | ||
|
||
const Presets: Record< | ||
HomePageHeroButtonType, | ||
Pick<HomePageHeroButtonBaseProps, "longText" | "shortText"> | ||
> = { | ||
join: { | ||
longText: "加入房间", | ||
shortText: "加入", | ||
}, | ||
create: { | ||
longText: "创建房间", | ||
shortText: "创建", | ||
}, | ||
schedule: { | ||
longText: "预定房间", | ||
shortText: "预定", | ||
}, | ||
}; | ||
|
||
export const HomePageHeroButton: React.FC<HomePageHeroButtonProps> = ({ type, onClick }) => { | ||
return <HomePageHeroButtonBase type={type} {...Presets[type]} onClick={onClick} />; | ||
}; | ||
|
||
export interface HomePageHeroButtonsProps { | ||
onJoin?: () => void; | ||
onCreate?: () => void; | ||
onSchedule?: () => void; | ||
} | ||
|
||
export const HomePageHeroButtons: React.FC<HomePageHeroButtonsProps> = ({ | ||
onJoin, | ||
onCreate, | ||
onSchedule, | ||
}) => { | ||
return ( | ||
<div className="home-page-hero-buttons"> | ||
<HomePageHeroButton type="join" onClick={onJoin} /> | ||
<HomePageHeroButton type="create" onClick={onCreate} /> | ||
<HomePageHeroButton type="schedule" onClick={onSchedule} /> | ||
</div> | ||
); | ||
}; |
80 changes: 80 additions & 0 deletions
80
packages/flat-components/src/components/HomePageHeroButton/style.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
.home-page-hero-buttons { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.home-page-hero-button { | ||
height: 72px !important; | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: 8px; | ||
background-color: white; | ||
font-size: 16px; | ||
border-color: white; | ||
margin-right: 16px; | ||
|
||
&:last-child { | ||
margin-right: 0; | ||
} | ||
|
||
.icon { | ||
display: inline-block; | ||
width: 44px; | ||
height: 44px; | ||
&.join { | ||
background-image: url(../../assets/buttons/join.svg); | ||
} | ||
&.create { | ||
background-image: url(../../assets/buttons/create.svg); | ||
} | ||
&.schedule { | ||
background-image: url(../../assets/buttons/schedule.svg); | ||
} | ||
@media screen and (max-width: 660px) { | ||
width: 24px; | ||
height: 24px; | ||
&.join { | ||
background-image: url(../../assets/buttons/join-small.svg); | ||
} | ||
&.create { | ||
background-image: url(../../assets/buttons/create-small.svg); | ||
} | ||
&.schedule { | ||
background-image: url(../../assets/buttons/schedule-small.svg); | ||
} | ||
} | ||
} | ||
|
||
.text { | ||
font-size: 16px; | ||
font-weight: 400; | ||
color: #444e60; | ||
padding-left: 14px; | ||
padding-right: 25px; | ||
|
||
&.short { | ||
display: none; | ||
} | ||
|
||
@media screen and (max-width: 660px) { | ||
font-size: 14px; | ||
padding-left: 6px; | ||
padding-right: 8px; | ||
|
||
&.long { | ||
display: none; | ||
} | ||
&.short { | ||
display: inline; | ||
} | ||
} | ||
} | ||
|
||
@media screen and (max-width: 660px) { | ||
flex: 1; | ||
height: 44px !important; | ||
border-radius: 9999px; | ||
margin-right: 8px; | ||
} | ||
} |