Skip to content

Commit

Permalink
feat(flat-component): add MainPageHeader component to storybook (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheerego7 committed May 18, 2021
1 parent 9d8258e commit 844e574
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import { MainPageHeader, MainPageHeaderProps } from ".";
import { BrowserRouter as Router } from "react-router-dom";

const storyMeta: Meta = {
title: "Components/MainPageHeader",
component: MainPageHeader,
};

export default storyMeta;

export const Overview: Story<MainPageHeaderProps> = args => (
<Router>
<div className="vh-75 mw8-ns">
<MainPageHeader {...args} />
</div>
</Router>
);
Overview.args = {
routePath: "/example/path",
title: "Example",
periodicUUID: "periodicUUID",
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.main-page-header-container {
display: flex;
align-items: center;
line-height: 24px;
margin-top: 24px;
margin-bottom: 16px;
}

.main-page-header-back {
color: #3381ff;
}

.main-page-header-title {
margin: 0;
font-size: 16px;
font-weight: 500;
color: #444e60;
line-height: 1;
}

.main-page-header-periodic-sign {
display: flex;
width: 36px;
height: 22px;
line-height: 22px;
margin-left: 8px;
background-color: #3381ff;
border-radius: 4px;
color: #fff;
justify-content: center;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import backSVG from "./icons/back.svg";
import "./index.less";

import React from "react";
import { Link } from "react-router-dom";
import { Divider } from "antd";

export interface MainPageHeaderProps {
routePath: string;
title: string;
periodicUUID?: string;
}

export const MainPageHeader: React.FC<MainPageHeaderProps> = ({
routePath,
title,
periodicUUID,
}) => {
return (
<div className="main-page-header-container">
<Link to={routePath}>
<div className="main-page-header-back">
<img src={backSVG} alt="back" />
<span>返回</span>
</div>
</Link>
<Divider type="vertical" />
<h1 className="main-page-header-title">{title}</h1>
{periodicUUID && <span className="main-page-header-periodic-sign">周期</span>}
</div>
);
};

0 comments on commit 844e574

Please sign in to comment.