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

React/create radio card #373

Merged
merged 6 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions frontend/src/components/atoms/RadioCard/RadioCardContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from "react";
import styled from "styled-components";

import { IRadio } from "@/api/RadioApi";
import { color } from "@/constants/styles";

export default (props: Pick<IRadio, "title" | "description">) => {
const { title, description } = props;

return (
<Wrapper>
<Title>{title}</Title>
<Description dangerouslySetInnerHTML={{ __html: description }} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここはmarkdownを受け取るようになるんだよね?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは前のAPIからhtmlを受け取ってます
別PRでmarkdownをパースして描画するようにしてます!

</Wrapper>
);
};

const Wrapper = styled.div`
width: 100%;
height: 100%;
`;

const Title = styled.h3`
font-size: 1.2rem;
color: ${color.BLUE};
text-align: center;
`;
const Description = styled.p``;
32 changes: 32 additions & 0 deletions frontend/src/components/atoms/RadioCard/RadioCardImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from "react";
import styled from "styled-components";

import { IRadio } from "@/api/RadioApi";
import { color } from "@/constants/styles";

export default (props: Pick<IRadio, "image">) => {
const { image } = props;

return (
<Wrapper>
<Image src={image} />
</Wrapper>
);
};

const Wrapper = styled.div`
width: 100%;
`;

const Image = styled.img`
object-fit: cover;
width: calc(100% + 6px);
margin-top: -3px;
margin-left: -3px;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
border-top: 3px solid ${color.SKY_BLUE};
border-left: 3px solid ${color.SKY_BLUE};
border-right: 3px solid ${color.SKY_BLUE};
border-bottom: 3px solid ${color.SKY_BLUE};
`;
53 changes: 53 additions & 0 deletions frontend/src/components/atoms/RadioCard/RadioCardPlayButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from "react";
import styled from "styled-components";

import { IRadio } from "@/api/RadioApi";
import { color } from "@/constants/styles";

export default (props: Pick<IRadio, "mp3" | "play_time">) => {
const { mp3, play_time } = props;

const isPlay = !false;

return (
<Wrapper>
<ButtonWrapper>
{isPlay ? (
<PlayButton className="fas fa-play" />
) : (
<PauseButton className="fas fa-pause" />
)}
</ButtonWrapper>
</Wrapper>
);
};

const Wrapper = styled.div`
position: absolute;
top: ${220 - 32 / 2}px;
left: 0;
right: 0;
margin: 0 auto;
width: 32px;
height: 32px;
background-color: ${color.ORANGE};
border: 3px solid ${color.VIVID_ORANGE};
border-radius: 50%;
`;

const ButtonWrapper = styled.div`
text-align: center;
margin-top: -2px;
`;

const ButtonBase = styled.i`
line-height: 32px;
font-size: 0.7rem;
color: ${color.WHITE};
`;

const PlayButton = styled(ButtonBase)`
padding-left: 2.5px;
`;

const PauseButton = styled(ButtonBase)``;
26 changes: 21 additions & 5 deletions frontend/src/components/molecules/RadioCard/RadioCardWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
import React from "react";
import styled from "styled-components";

import card from "./radio-card.png";
import { IRadio } from "@/api/RadioApi";
import { color } from "@/constants/styles";

export default () => <RadioCardWrapperStyle />;
import CardImage from "@/components/atoms/RadioCard/RadioCardImage";
import CardContent from "@/components/atoms/RadioCard/RadioCardContent";
import PlayButton from "@/components/atoms/RadioCard/RadioCardPlayButton";

export default (props: IRadio) => {
const { title, description, mp3, image, play_time } = props;

return (
<RadioCardWrapperStyle>
<CardImage image={image} />
<PlayButton mp3={mp3} play_time={play_time} />
<CardContent title={title} description={description} />
</RadioCardWrapperStyle>
);
};

const RadioCardWrapperStyle = styled.div`
width: 282px;
width: 280px;
height: 445px;
background-image: url(${card});
background-size: cover;
border-radius: 8px;
border: 3px solid ${color.SKY_BLUE};
position: relative;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,50 @@ import RadioHistoryFeature from "@/components/atoms/RadioHistory/RadioHistoryFea

import RadioCardWrapper from "@/components/molecules/RadioCard/RadioCardWrapper";

export default () => (
<Wrapper>
<RadioHistoryFeature />
<RadioHistoryContentArea>
<Title>category</Title>
<RadioDateButtonWrapper>
<RadioDateButton name="201804" type="button">
2018/04
</RadioDateButton>
<RadioDateButton name="201803" type="button">
2018/03
</RadioDateButton>
<RadioDateButton name="201802" type="button">
2018/02
</RadioDateButton>
<RadioDateButton name="201801" type="button">
2018/01
</RadioDateButton>
</RadioDateButtonWrapper>
<RadioCardsWrapper>
<RadioCardWrapper />
<RadioCardWrapper />
<RadioCardWrapper />
</RadioCardsWrapper>
<RadioCardsWrapper>
<RadioCardWrapper />
<RadioCardWrapper />
<RadioCardWrapper />
</RadioCardsWrapper>
<RadioCardsWrapper>
<RadioCardWrapper />
<RadioCardWrapper />
<RadioCardWrapper />
</RadioCardsWrapper>
<MoreButton to="" />
</RadioHistoryContentArea>
</Wrapper>
);
import CircleSpinner from "@/components/atoms/Spinners/CircleSpinner";

import { IRadio } from "@/api/RadioApi";

interface IProps {
radios: IRadio[];
}

export default (props: IProps) => {
const { radios } = props;

return (
<Wrapper>
<RadioHistoryFeature />
<RadioHistoryContentArea>
<Title>category</Title>
<RadioDateButtonWrapper>
<RadioDateButton name="201804" type="button">
2018/04
</RadioDateButton>
<RadioDateButton name="201803" type="button">
2018/03
</RadioDateButton>
<RadioDateButton name="201802" type="button">
2018/02
</RadioDateButton>
<RadioDateButton name="201801" type="button">
2018/01
</RadioDateButton>
</RadioDateButtonWrapper>
{radios ? (
<RadioCardsWrapper>
{radios.map(radio => (
<RadioCardWrapper key={radio.id} {...radio} />
))}
</RadioCardsWrapper>
) : (
<CircleSpinner />
)}
<MoreButton to="" />
</RadioHistoryContentArea>
</Wrapper>
);
};

const Wrapper = styled.div`
width: 100%;
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/constants/styles/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ interface IColor {
}

export default {
ORANGE: "#edb600",
ORANGE: "#ECB73F",
VIVID_ORANGE: "#E59134",
BLUE: "#00AFEC",
SKY_BLUE: "#A8E1E3",
BLACK: "#565A62",
Expand Down
50 changes: 33 additions & 17 deletions frontend/src/pages/RadioHistory.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import styled from "styled-components";
import { observer } from "mobx-react-lite";

import { device } from "@/constants/styles";

Expand All @@ -12,23 +13,38 @@ import RadioHistoryWrapper from "@/components/molecules/RadioHistory/RadioHistor
import RadioSearcher from "@/components/molecules/RadioSearcher";
import BlogWrapper from "@/components/molecules/Blogs/BlogWrapper";

export default () => (
<div>
<HeroArea>Radio History</HeroArea>
<Container>
<Sidebar>
<RadioSearcher />
<AboutSidebar />
<PopularRadioWrapper />
<TweetStream />
</Sidebar>
<MainContentWrapper>
<RadioHistoryWrapper />
<BlogWrapper />
</MainContentWrapper>
</Container>
</div>
);
import RootStore from "@/stores/RootStore";

interface IProps {
rootStore?: RootStore;
}

export default observer((props: IProps) => {
const { rootStore } = props;
const { radioStore } = rootStore!;

React.useEffect(() => {
radioStore.fetchRadios();
}, []);

return (
<div>
<HeroArea>Radio History</HeroArea>
<Container>
<Sidebar>
<RadioSearcher />
<AboutSidebar />
<PopularRadioWrapper />
<TweetStream />
</Sidebar>
<MainContentWrapper>
<RadioHistoryWrapper radios={radioStore.radios!} />
<BlogWrapper />
</MainContentWrapper>
</Container>
</div>
);
});

const Container = styled.div`
display: flex;
Expand Down