Skip to content

Commit

Permalink
[Header/Topics][l]: topics page is now fully themed according to acti…
Browse files Browse the repository at this point in the history
…ve topic -- refs #105
  • Loading branch information
demenech committed Sep 15, 2022
1 parent 9dee544 commit 5f400c6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
12 changes: 11 additions & 1 deletion components/_shared/carousel/card/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,19 @@ interface Item {
const Carousel: React.FC<{
items: Item[];
itemOnClick: (item: any) => any;
}> = ({ items, itemOnClick }) => {
color?: string;
}> = ({ items, itemOnClick, color }) => {
const prevEl = '.nav-prev-button';
const nextEl = '.nav-next-button';

let css;
if(color) {
css = `
.swiper-bullet-active {
background: ${color} !important;
}`
}

return (
<>
<div className="relative">
Expand Down Expand Up @@ -86,6 +95,7 @@ const Carousel: React.FC<{
</SwiperSlide>
))}
</Swiper>
<style>{css}</style>
<div className="pagination text-center" />
</div>
</>
Expand Down
15 changes: 13 additions & 2 deletions components/_shared/image_header/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
const Badge: React.FC<{ text: string }> = ({ text }) => {
const Badge: React.FC<{ text: string; color?: string }> = ({
text,
color,
}) => {

return (
<>
<span className="bg-[#80E47E] px-6 py-2 rounded-full">{text}</span>
<span
className={`px-6 py-2 rounded-full font-medium ${
color ? 'text-white' : ''
}`}
style={{ backgroundColor: color || '#80E47E' }}
>
{text}
</span>
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion components/_shared/image_header/ImageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const ImageHeader: React.FC<ImageHeaderProps> = ({
</p>
</div>
<div className="pb-[3rem]">
<Badge text={badgeText} />
<Badge text={badgeText} color={color} />
</div>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion components/topic/MainOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,15 @@ const MainOptions: React.FC<any> = ({
fixTranslations(activeTopic);
subtopics.forEach((subtopic) => fixTranslations(subtopic));

const color = configs?.filter((el) => el.name == topic)[0]?.color;

return (
<>
<div className="mb-20" id="header">
<TopicHeader
topic={activeTopic}
datasetsCount={activeTopic.package_count}
color={configs?.filter((el) => el.name == topic)[0]?.color}
color={color}
/>
</div>
{subtopics?.length > 0 && (
Expand All @@ -167,6 +169,7 @@ const MainOptions: React.FC<any> = ({
<SubtopicsCarousel
subtopics={subtopics}
subtopicOnClick={onSutopicClick}
color={color}
/>
</div>
)}
Expand Down
4 changes: 2 additions & 2 deletions components/topic/SubtopicsCarousel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Carousel from '../_shared/carousel/card/Carousel';

const SubtopicsCarousel: React.FC<any> = ({ subtopics, subtopicOnClick }) => {
const SubtopicsCarousel: React.FC<any> = ({ subtopics, subtopicOnClick, color }) => {
const items = subtopics.map((subtopic) => {
return {
name: subtopic.name,
Expand All @@ -22,7 +22,7 @@ const SubtopicsCarousel: React.FC<any> = ({ subtopics, subtopicOnClick }) => {

return (
<>
<Carousel items={items} itemOnClick={subtopicOnClick} />
<Carousel color={color} items={items} itemOnClick={subtopicOnClick} />
</>
);
};
Expand Down

0 comments on commit 5f400c6

Please sign in to comment.