- {heading &&
{heading} }
-
-
-
- {prereqs && (
-
- Pre-Requisites
-
+
+ {heading && (
+ <>
+
{heading}
+
+ >
)}
-
{prereqs && mapPrerequisites(prereqs)}
+
{links && mapLinks(links)}
{hasMessage && userMessage()}
+ {prereqs && (
+
+
+
+ Pre-Requisites
+
+
+ )}
+
{prereqs && mapPrerequisites(prereqs)}
)
}
diff --git a/src/components/Typography/Text.tsx b/src/components/Typography/Text.tsx
index 06cd96c..facdaa2 100644
--- a/src/components/Typography/Text.tsx
+++ b/src/components/Typography/Text.tsx
@@ -2,7 +2,7 @@ import React from 'react'
import cn from 'classnames'
import type {PropsWithChildren} from 'react'
-type TextComponent = 'p' | 'span' | 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
+type TextComponent = 'p' | 'span' | 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'a'
type TextSizes = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl'
type FontWeight = 'font-medium' | 'font-normal' | 'font-black' | 'font-bold'
From f26ef2fc369c20b7b27d1551a9978039baebb2ec Mon Sep 17 00:00:00 2001
From: m15e <6917497+m15e@users.noreply.github.com>
Date: Tue, 1 Jun 2021 15:24:44 +0800
Subject: [PATCH 6/6] add: progress circle, sidebar components
---
.../ProgressCircle/ProgressCircle.tsx | 65 +++++++++++++++++++
src/components/Sidebar/Sidebar.stories.tsx | 4 +-
src/components/Sidebar/Sidebar.tsx | 9 +++
tailwind.config.js | 4 ++
4 files changed, 80 insertions(+), 2 deletions(-)
create mode 100644 src/components/ProgressCircle/ProgressCircle.tsx
diff --git a/src/components/ProgressCircle/ProgressCircle.tsx b/src/components/ProgressCircle/ProgressCircle.tsx
new file mode 100644
index 0000000..9fc61be
--- /dev/null
+++ b/src/components/ProgressCircle/ProgressCircle.tsx
@@ -0,0 +1,65 @@
+const cleanPercentage = percentage => {
+ const isNegativeOrNaN = !Number.isFinite(+percentage) || percentage < 0 // we can set non-numbers to 0 here
+ const isTooHigh = percentage > 100
+ return isNegativeOrNaN ? 0 : isTooHigh ? 100 : +percentage
+}
+
+const Circle = ({color, percentage, stroke}) => {
+ const r = 50
+ const circ = 2 * Math.PI * r
+ const strokePct = ((100 - percentage) * circ) / 100 // where stroke will start, e.g. from 15% to 100%.
+ const circleColor = stroke ? stroke : color
+ return (
+
+ )
+}
+
+const Percent = ({percentage}) => {
+ return (
+
+ {percentage.toFixed(0)}%
+
+ )
+}
+
+export const ProgressCircle = percentage => {
+ const pct = cleanPercentage(percentage)
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ )
+}
diff --git a/src/components/Sidebar/Sidebar.stories.tsx b/src/components/Sidebar/Sidebar.stories.tsx
index fb5729f..081e03b 100644
--- a/src/components/Sidebar/Sidebar.stories.tsx
+++ b/src/components/Sidebar/Sidebar.stories.tsx
@@ -96,14 +96,14 @@ const Template: Story = args => {
-
+
-
+
diff --git a/src/components/Sidebar/Sidebar.tsx b/src/components/Sidebar/Sidebar.tsx
index 0394a53..d021669 100644
--- a/src/components/Sidebar/Sidebar.tsx
+++ b/src/components/Sidebar/Sidebar.tsx
@@ -4,6 +4,7 @@ import {H5, Text} from '../Typography/Text'
import {Button} from '../Button/Button'
import {Icon} from '../Icons/Icon'
import {Avatar} from '../Avatar/Avatar'
+import {ProgressCircle} from '../ProgressCircle/ProgressCircle'
const messageIcon = () => (
@@ -18,6 +19,7 @@ export function Sidebar({
heading = '',
hasMessage = false,
borderLeft = false,
+ progressPct,
links,
prereqs,
className,
@@ -27,6 +29,7 @@ export function Sidebar({
heading: string
hasMessage: boolean
borderLeft: boolean
+ progressPct: number
icon: React.ReactType
links: []
prereqs: []
@@ -106,6 +109,12 @@ export function Sidebar({
)}
{prereqs && mapPrerequisites(prereqs)}
+ {progressPct && (
+ <>
+
+ {ProgressCircle(progressPct)}
+ >
+ )}
)
}
diff --git a/tailwind.config.js b/tailwind.config.js
index 2849da3..cf297e9 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -48,6 +48,10 @@ module.exports = {
},
dropShadow: {
'button-hover': '-4px 4px 8px --color-primary-500'
+ },
+ strokeWidth: {
+ 5: '5',
+ 6: '6'
}
}
},