-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve CSS, read properties from JSON
Start work on progress bars
- Loading branch information
1 parent
309877f
commit 6d24629
Showing
8 changed files
with
158 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
import "./App.css"; | ||
import ScoreCard from "./components/ScoreCard.tsx"; | ||
import SummaryCard from "./components/SummaryCard.tsx"; | ||
import data from "./assets/data.json"; | ||
|
||
export type DataEntry = { | ||
category: string; | ||
score: number; | ||
icon: string; | ||
}; | ||
|
||
export type ScoreCardProps = { | ||
score: number; | ||
message: string; | ||
description: string; | ||
}; | ||
|
||
const overviewData: ScoreCardProps = { | ||
score: 76, | ||
message: "Great", | ||
description: | ||
"You scored higher than 65% of people who have taken these tests.", | ||
}; | ||
|
||
export default function App() { | ||
return ( | ||
<> | ||
<ScoreCard /> | ||
<SummaryCard /> | ||
<ScoreCard {...overviewData} /> | ||
<SummaryCard {...data} /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import styled from "styled-components"; | ||
import { primary, neutral } from "./colors.json"; | ||
import changeAlpha from "./alpha"; | ||
|
||
type ProgressbarProps = { | ||
icon: string; | ||
category: string; | ||
score: number; | ||
}; | ||
|
||
const Graph = styled.div<{ $color: string }>` | ||
display: flex; | ||
padding: 0.5rem; | ||
color: ${(props) => props.$color}; | ||
background-color: ${(props) => changeAlpha(props.$color, 10)}; | ||
`; | ||
|
||
export default function Progressbar({ | ||
icon, | ||
category, | ||
score, | ||
}: ProgressbarProps) { | ||
const colorsArr = Object.keys(primary); | ||
|
||
const barColor = (i: number) => { | ||
while (i >= colorsArr.length) { | ||
i -= colorsArr.length; | ||
} | ||
return colorsArr[i % colorsArr.length]; | ||
}; | ||
|
||
return ( | ||
<Graph $color={barColor(key)}> | ||
<img src={icon} aria-hidden alt="icon" /> | ||
<span className="title">{category}</span> | ||
<div> | ||
<span className="score">{score}</span> | ||
<span className="percent">100</span> | ||
</div> | ||
</Graph> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Gets the hsla value and changes the last property | ||
* | ||
* I am aware this is a hilariously overengineered solution, | ||
* and I'm proud of it. | ||
*/ | ||
export default function changeAlpha(color: string, alphaVal: number): string { | ||
const params: string[] = color.split(", "); | ||
let transparency: number = alphaVal / 100; | ||
params[3] = transparency.toString() + ")"; | ||
return params.join(", "); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
{ | ||
"primary": { | ||
"light-red": "hsl(0, 100%, 67%)", | ||
"orange-yellow": "hsl(39, 100%, 56%)", | ||
"green-teal": "hsl(166, 100%, 37%)", | ||
"cobalt-blue": "hsl(234, 85%, 45%)" | ||
"light-red": "hsla(0, 100%, 67%, 1)", | ||
"orange-yellow": "hsla(39, 100%, 56%, 1)", | ||
"green-teal": "hsla(166, 100%, 37%, 1)", | ||
"cobalt-blue": "hsla(234, 85%, 45%, 1)" | ||
}, | ||
"gradient": { | ||
"light-slate-blue": "hsl(252, 100%, 67%)", | ||
"light-royal-blue": "hsl(241, 81%, 54%)", | ||
"light-slate-blue": "hsla(252, 100%, 67%, 1)", | ||
"light-royal-blue": "hsla(241, 81%, 54%, 1)", | ||
"violet-blue": "hsla(256, 72%, 46%, 1)", | ||
"persian-blue": "hsla(241, 72%, 46%, 0)" | ||
}, | ||
"neutral": { | ||
"white": "hsl(0, 0%, 100%)", | ||
"pale-blue": "hsl(221, 100%, 96%)", | ||
"light-lavender": "hsl(241, 100%, 89%)", | ||
"dark-gray-blue": "hsl(224, 30%, 27%)" | ||
"white": "hsla(0, 0%, 100%, 1)", | ||
"pale-blue": "hsla(221, 100%, 96%, 1)", | ||
"light-lavender": "hsla(241, 100%, 89%, 1)", | ||
"dark-gray-blue": "hsla(224, 30%, 27%, 1)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters