Skip to content

Commit

Permalink
feat: implement a level pill
Browse files Browse the repository at this point in the history
this clsoes #248
  • Loading branch information
marianzburlea committed Sep 21, 2019
1 parent 9284a64 commit c926a45
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/component/_dumb/pill/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './pill.component'
13 changes: 13 additions & 0 deletions src/component/_dumb/pill/pill.component.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react'
import { StyledPillHalf, StyledPill } from './pill.style'

const Pill = ({ label, value }) => {
return (
<StyledPill>
<StyledPillHalf>{label}</StyledPillHalf>
<StyledPillHalf value={value}>{value}</StyledPillHalf>
</StyledPill>
)
}

export default Pill
31 changes: 31 additions & 0 deletions src/component/_dumb/pill/pill.style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import styled from 'styled-components'

const colorMap = {
starter: '#c00',
junior: '#036',
mid: '#f00',
senior: '#0f0',
}

export const StyledPillHalf = styled.span`
flex-basis: 50%;
padding: 0.2rem 0.5rem;
&:first-child {
background-color: #fff;
color: #000;
}
&:last-child {
background-color: ${({ value }) => colorMap[value]};
color: #fff;
text-transform: capitalize;
}
`

export const StyledPill = styled.span`
display: flex;
align-items: center;
border-radius: 1rem;
overflow: hidden;
`
2 changes: 1 addition & 1 deletion src/component/course/course.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default {
placeholder: 'Select difficulty',
label: 'Level of knowledge required to uderstand the course',
defaultValue: '',
optionList: ["starter", "junior", "mid", "senior"],
optionList: ['', 'starter', 'junior', 'mid', 'senior'],
edit: true,
visible: true,
value: ''
Expand Down
17 changes: 11 additions & 6 deletions src/component/home/home.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import HeaderTitle from '../_dumb/header-title';
import { db } from '../data/firebase';
import { debounce } from 'lodash'
import { navigate } from '@reach/router'
import { StyledCourse, StyledCourseList, StyledWatchNow } from './home.style';
import { StyledCourse, StyledCourseList, StyledWatchNow, StyledButtonWrapper } from './home.style';
import Pill from '../_dumb/pill';

const Home = () => {
const [pageY, setPageY] = useState(0)
Expand Down Expand Up @@ -43,14 +44,18 @@ const Home = () => {
}

const renderCourseList = () => {
return data.courseList.map(({ title, id, description, totalDuration, externalThumbnail }) => (
return data.courseList.map(({ title, id, description, totalDuration, externalThumbnail, courseLevel }) => (
<StyledCourse key={id} externalThumbnail={externalThumbnail}>
<HeaderTitle text={title} tag="h2" fontSize="1.2rem" />
<p>{description}</p>
<div>Watch time: {totalDuration}</div>
<StyledWatchNow
onClick={() => goToCoursePlayList(id)}
>Watch now</StyledWatchNow>
<div>Duration: {totalDuration}</div>
<StyledButtonWrapper>

<StyledWatchNow
onClick={() => goToCoursePlayList(id)}
>Watch now</StyledWatchNow>
{courseLevel && <Pill label="Level" value={courseLevel} />}
</StyledButtonWrapper>
</StyledCourse>
));
};
Expand Down
5 changes: 5 additions & 0 deletions src/component/home/home.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ export const StyledCourseList = styled.div `
flex-wrap: wrap;
`

export const StyledButtonWrapper = styled.div `
display: flex;
justify-content: space-around;
`

export const StyledWatchNow = styled.button `
background-color: #d52027;
color: #fff;
Expand Down

0 comments on commit c926a45

Please sign in to comment.