-
-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: two factor authentication segment in preferences with mocked st…
…ate (#600)
- Loading branch information
Showing
32 changed files
with
618 additions
and
247 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.
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
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 { FunctionalComponent, ComponentChild } from 'preact'; | ||
|
||
interface Props { | ||
className?: string; | ||
disabled?: boolean; | ||
left?: ComponentChild[]; | ||
right?: ComponentChild[]; | ||
text?: string; | ||
} | ||
|
||
/** | ||
* Input that can be decorated on the left and right side | ||
*/ | ||
export const DecoratedInput: FunctionalComponent<Props> = ({ | ||
className = '', | ||
disabled = false, | ||
left, | ||
right, | ||
text, | ||
}) => { | ||
const base = | ||
'rounded py-1.5 px-3 text-input my-1 h-8 flex flex-row items-center gap-4'; | ||
const stateClasses = disabled | ||
? 'no-border bg-grey-5' | ||
: 'border-solid border-1 border-gray-300'; | ||
const classes = `${base} ${stateClasses} ${className}`; | ||
|
||
return ( | ||
<div className={classes}> | ||
{left} | ||
<div className="flex-grow"> | ||
<input | ||
type="text" | ||
className="w-full no-border color-black" | ||
disabled={disabled} | ||
value={text} | ||
/> | ||
</div> | ||
{right} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,38 @@ | ||
import { FunctionComponent } from 'preact'; | ||
import { Icon, IconType } from './Icon'; | ||
|
||
const ICON_BUTTON_TYPES: { | ||
[type: string]: { className: string }; | ||
} = { | ||
normal: { | ||
className: '', | ||
}, | ||
primary: { | ||
className: 'info', | ||
}, | ||
}; | ||
|
||
export type IconButtonType = keyof typeof ICON_BUTTON_TYPES; | ||
|
||
interface IconButtonProps { | ||
interface Props { | ||
/** | ||
* onClick - preventDefault is handled within the component | ||
*/ | ||
onClick: () => void; | ||
|
||
type: IconButtonType; | ||
|
||
className?: string; | ||
|
||
iconType: IconType; | ||
icon: IconType; | ||
} | ||
|
||
/** | ||
* CircleButton component with an icon for SPA | ||
* IconButton component with an icon | ||
* preventDefault is already handled within the component | ||
*/ | ||
export const IconButton: FunctionComponent<IconButtonProps> = ({ | ||
export const IconButton: FunctionComponent<Props> = ({ | ||
onClick, | ||
type, | ||
className, | ||
iconType, | ||
icon, | ||
}) => { | ||
const click = (e: MouseEvent) => { | ||
e.preventDefault(); | ||
onClick(); | ||
}; | ||
const typeProps = ICON_BUTTON_TYPES[type]; | ||
return ( | ||
<button | ||
className={`sn-icon-button ${typeProps.className} ${className ?? ''}`} | ||
className={`no-border bg-transparent hover:brightness-130 p-0 ${ | ||
className ?? '' | ||
}`} | ||
onClick={click} | ||
> | ||
<Icon type={iconType} /> | ||
<Icon type={icon} /> | ||
</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,22 @@ | ||
import { FunctionalComponent } from 'preact'; | ||
|
||
interface Props { | ||
text?: string; | ||
disabled?: boolean; | ||
className?: string; | ||
} | ||
|
||
export const Input: FunctionalComponent<Props> = ({ | ||
className = '', | ||
disabled = false, | ||
text, | ||
}) => { | ||
const base = `rounded py-1.5 px-3 text-input my-1 h-8`; | ||
const stateClasses = disabled | ||
? 'no-border bg-grey-5' | ||
: 'border-solid border-1 border-gray-300'; | ||
const classes = `${base} ${stateClasses} ${className}`; | ||
return ( | ||
<input type="text" className={classes} disabled={disabled} value={text} /> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { FunctionComponent } from 'preact'; | ||
import { Icon, IconType } from './Icon'; | ||
|
||
type ButtonType = 'normal' | 'primary'; | ||
|
||
interface Props { | ||
/** | ||
* onClick - preventDefault is handled within the component | ||
*/ | ||
onClick: () => void; | ||
|
||
type: ButtonType; | ||
|
||
className?: string; | ||
|
||
icon: IconType; | ||
} | ||
|
||
/** | ||
* IconButton component with an icon | ||
* preventDefault is already handled within the component | ||
*/ | ||
export const RoundIconButton: FunctionComponent<Props> = ({ | ||
onClick, | ||
type, | ||
className, | ||
icon: iconType, | ||
}) => { | ||
const click = (e: MouseEvent) => { | ||
e.preventDefault(); | ||
onClick(); | ||
}; | ||
const classes = type === 'primary' ? 'info ' : ''; | ||
return ( | ||
<button | ||
className={`sn-icon-button ${classes} ${className ?? ''}`} | ||
onClick={click} | ||
> | ||
<Icon type={iconType} /> | ||
</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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
55 changes: 0 additions & 55 deletions
55
app/assets/javascripts/components/preferences/preferences.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.