Skip to content

Commit

Permalink
feat: add colors to sections in home page
Browse files Browse the repository at this point in the history
  • Loading branch information
marianzburlea committed Sep 7, 2019
1 parent 5c0a233 commit 3122e89
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/component/lecture-info/lecture-info.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import HeaderTitle from '../_dumb/header-title';
import ResponsiveThumbnail from '../_dumb/responsive-thumbnail';
import { StyledLectureInfo } from './lecture-info.style';

const LectureInfo = ({ title, id, description, imagePath, youtubeVideoId, youtubePlaylistId }) => {
const LectureInfo = ({ title, id, description, imagePath, youtubeVideoId, sectionOrder }) => {
const getImagePath = () =>
imagePath ? imagePath : `http://img.youtube.com/vi/${youtubeVideoId}/0.jpg`;
const getYoutubePath = () => `/video/${youtubeVideoId}`;

// TODO: use this later on when linking to youtube
// `https://www.youtube.com/watch?v=${youtubeVideoId}&list=${youtubePlaylistId}&t=0s`;

const headerTitlePropList = {
text: title,
tag: 'a',
Expand All @@ -19,7 +16,7 @@ const LectureInfo = ({ title, id, description, imagePath, youtubeVideoId, youtub
};

return (
<StyledLectureInfo>
<StyledLectureInfo sectionOrder={sectionOrder}>
<div>
<ResponsiveThumbnail imagePath={getImagePath()} />
</div>
Expand Down
27 changes: 26 additions & 1 deletion src/component/lecture-info/lecture-info.style.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
import styled from 'styled-components'
const colorList = [
"#1abc9c",
"#2ecc71",
"#3498db",
"#9b59b6",
"#34495e",
"#16a085",
"#27ae60",
"#2980b9",
"#8e44ad",
"#2c3e50",
// "#f1c40f",
"#e67e22",
"#e74c3c",
// "#ecf0f1",
"#95a5a6",
"#f39c12",
"#d35400",
"#c0392b",
// "#bdc3c7",
"#7f8c8d"
].sort((a, b) => Math.random() - 0.5)

export const StyledLectureInfo = styled.div`
width: 220px;
padding: 6px 12px 6px 0;
padding: 6px;
margin-right: 6px;
margin-bottom: 6px;
background-color: ${({ sectionOrder }) => colorList[sectionOrder]}
`
16 changes: 11 additions & 5 deletions src/component/lecture-slider/lecture-slider.component.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Fragment } from 'react';
import LectureInfo from '../lecture-info';
import { StyledLectureSlider } from './lecture-slider.style';

Expand All @@ -7,15 +7,21 @@ const LectureSlider = ({ lectureList, courseId, youtubePlaylistId, sectionList }
<StyledLectureSlider>
{sectionList.map(section => {
return (
<div key={section.id}>
<div>{section.title}</div>
<Fragment key={section.id}>
{
lectureList
.filter(lecture => lecture.section.id === section.id)
.sort((a, b) => a.order - b.order)
.map(({ id, ...lecture }) => <LectureInfo key={id} {...lecture} youtubePlaylistId={youtubePlaylistId} />)
.map(({ id, ...lecture }) => (
<LectureInfo
key={id}
{...lecture}
sectionOrder={section.order}
youtubePlaylistId={youtubePlaylistId}
/>
))
}
</div>
</Fragment>
)
})}
</StyledLectureSlider>
Expand Down

0 comments on commit 3122e89

Please sign in to comment.