-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
96 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
10 changes: 10 additions & 0 deletions
10
src/features/surveys/features/SurveyDisplay/utils/getFontColor.ts
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,10 @@ | ||
export const getFontColor = (color?: string | null) => { | ||
if (!color) return '#000000'; | ||
|
||
const hex = color.replace('#', ''); | ||
const r = parseInt(hex.substr(0, 2), 16); | ||
const g = parseInt(hex.substr(2, 2), 16); | ||
const b = parseInt(hex.substr(4, 2), 16); | ||
|
||
return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? '#000000' : '#ffffff'; | ||
}; |
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
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,33 +1,56 @@ | ||
import { colord, extend } from 'colord'; | ||
import mixPlugin from 'colord/plugins/mix'; | ||
|
||
interface ProgressbarProps { | ||
currentStep: number; | ||
totalSteps: number; | ||
isSubmitted?: boolean; | ||
accentColor?: string | null; | ||
} | ||
|
||
export default function Progressbar({ | ||
currentStep, | ||
totalSteps, | ||
isSubmitted, | ||
accentColor, | ||
}: ProgressbarProps) { | ||
const percentage = | ||
((currentStep - 1 + (isSubmitted ? 1 : 0)) / totalSteps) * 100; | ||
|
||
const getBackgroundColor = () => { | ||
if (!accentColor) return undefined; | ||
|
||
extend([mixPlugin]); | ||
|
||
const color = colord(accentColor); | ||
const newc = color.tints(3).map((c) => c.toHex()); | ||
|
||
return newc[1]; | ||
}; | ||
|
||
return ( | ||
<div className="relative mt-4 h-[24px] w-full overflow-hidden rounded-lg bg-indigo-100"> | ||
<div | ||
className="relative mt-4 h-[12px] w-full overflow-hidden rounded-lg bg-indigo-100" | ||
style={{ background: getBackgroundColor() }} | ||
> | ||
<div | ||
data-testid="progressbar" | ||
style={{ width: `${percentage}%` }} | ||
style={{ | ||
width: `${percentage}%`, | ||
backgroundColor: accentColor ?? undefined, | ||
}} | ||
className="h-full bg-indigo-300 transition-all duration-300" | ||
></div> | ||
<span className="text-purple absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-xs font-semibold"> | ||
|
||
{/* <span className="text-purple absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-xs font-semibold"> | ||
{isSubmitted ? ( | ||
<span>Submitting...</span> | ||
) : ( | ||
<span> | ||
{currentStep - 1} of {totalSteps} completed | ||
</span> | ||
)} | ||
</span> | ||
</span> */} | ||
</div> | ||
); | ||
} |