-
-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(preferences): 2FA activation dialog with mocked state (#605)
- Loading branch information
Showing
31 changed files
with
845 additions
and
278 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,28 @@ | ||
import { FunctionComponent } from 'preact'; | ||
|
||
const baseClass = `rounded px-4 py-1.75 font-bold text-sm fit-content cursor-pointer`; | ||
|
||
const normalClass = `${baseClass} bg-default color-text border-solid border-gray-300 border-1 \ | ||
focus:bg-contrast hover:bg-contrast`; | ||
const primaryClass = `${baseClass} no-border bg-info color-info-contrast hover:brightness-130 \ | ||
focus:brightness-130`; | ||
|
||
export const Button: FunctionComponent<{ | ||
className?: string; | ||
type: 'normal' | 'primary'; | ||
label: string; | ||
onClick: () => void; | ||
}> = ({ type, label, className = '', onClick }) => { | ||
const buttonClass = type === 'primary' ? primaryClass : normalClass; | ||
return ( | ||
<button | ||
className={`${buttonClass} ${className}`} | ||
onClick={(e) => { | ||
onClick(); | ||
e.preventDefault(); | ||
}} | ||
> | ||
{label} | ||
</button> | ||
); | ||
}; |
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,38 @@ | ||
import { FunctionComponent } from 'preact'; | ||
|
||
export const CircleProgress: FunctionComponent<{ | ||
percent: number; | ||
className?: string; | ||
}> = ({ percent, className = '' }) => { | ||
const size = 16; | ||
const ratioStrokeRadius = 0.25; | ||
const outerRadius = size / 2; | ||
|
||
const radius = outerRadius * (1 - ratioStrokeRadius); | ||
const stroke = outerRadius - radius; | ||
|
||
const circumference = radius * 2 * Math.PI; | ||
const offset = circumference - (percent / 100) * circumference; | ||
|
||
const transition = `transition: 0.35s stroke-dashoffset;`; | ||
const transform = `transform: rotate(-90deg);`; | ||
const transformOrigin = `transform-origin: 50% 50%;`; | ||
const dasharray = `stroke-dasharray: ${circumference} ${circumference};`; | ||
const dashoffset = `stroke-dashoffset: ${offset};`; | ||
const style = `${transition} ${transform} ${transformOrigin} ${dasharray} ${dashoffset}`; | ||
return ( | ||
<div className="h-5 w-5 min-w-5 min-h-5"> | ||
<svg viewBox={`0 0 ${size} ${size}`}> | ||
<circle | ||
stroke="#086DD6" | ||
stroke-width={stroke} | ||
fill="transparent" | ||
r={radius} | ||
cx="50%" | ||
cy="50%" | ||
style={style} | ||
/> | ||
</svg> | ||
</div> | ||
); | ||
}; |
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,27 @@ | ||
import { FunctionalComponent } from 'preact'; | ||
import { useEffect, useState } from 'preact/hooks'; | ||
import { CircleProgress } from './CircleProgress'; | ||
|
||
/** | ||
* Circular progress bar which runs in a specified time interval | ||
* @param time - time interval in ms | ||
*/ | ||
export const CircleProgressTime: FunctionalComponent<{ time: number }> = ({ | ||
time, | ||
}) => { | ||
const [percent, setPercent] = useState(0); | ||
const interval = time / 100; | ||
useEffect(() => { | ||
const tick = setInterval(() => { | ||
if (percent === 100) { | ||
setPercent(0); | ||
} else { | ||
setPercent(percent + 1); | ||
} | ||
}, interval); | ||
return () => { | ||
clearInterval(tick); | ||
}; | ||
}); | ||
return <CircleProgress percent={percent} />; | ||
}; |
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 was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
app/assets/javascripts/preferences/PreferencesMenuView.tsx
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,20 @@ | ||
import { observer } from 'mobx-react-lite'; | ||
import { FunctionComponent } from 'preact'; | ||
import { MenuItem } from './components'; | ||
import { PreferencesMenu } from './preferences-menu'; | ||
|
||
export const PreferencesMenuView: FunctionComponent<{ | ||
menu: PreferencesMenu; | ||
}> = observer(({ menu }) => ( | ||
<div className="min-w-55 overflow-y-auto flex flex-col px-3 py-6"> | ||
{menu.menuItems.map((pref) => ( | ||
<MenuItem | ||
key={pref.id} | ||
iconType={pref.icon} | ||
label={pref.label} | ||
selected={pref.selected} | ||
onClick={() => menu.selectPane(pref.id)} | ||
/> | ||
))} | ||
</div> | ||
)); |
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 was deleted.
Oops, something went wrong.
81 changes: 0 additions & 81 deletions
81
app/assets/javascripts/preferences/models/two-factor-auth.ts
This file was deleted.
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
Oops, something went wrong.