Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: selectable ui elements #714

Merged
merged 6 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/Jars.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
color: var(--bs-gray-500);
border: 1px solid var(--bs-gray-500);
border-radius: 50%;
cursor: help;
}

.jarsContainer {
Expand Down
4 changes: 2 additions & 2 deletions src/components/MainWalletView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default function MainWalletView({ wallet }: MainWalletViewProps) {
.catch((err) => {
if (abortCtrl.signal.aborted) return
const message = err.message || t('current_wallet.error_loading_failed')
!abortCtrl.signal.aborted && setAlert({ variant: 'danger', message })
setAlert({ variant: 'danger', message })
})
.finally(() => {
if (abortCtrl.signal.aborted) return
Expand All @@ -134,7 +134,7 @@ export default function MainWalletView({ wallet }: MainWalletViewProps) {
</rb.Row>
)}

{currentWalletInfo && jars && isAccountOverlayShown && (
{currentWalletInfo && jars && (
<JarDetailsOverlay
jars={jars}
initialJarIndex={selectedJarIndex}
Expand Down
22 changes: 9 additions & 13 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,8 @@ const TrailingNav = ({ joiningRoute, onClick }: TrailingNavProps) => {
return (
<rb.Nav className="justify-content-center align-items-stretch">
{joiningRoute && (
<rb.Nav.Item className="d-flex align-items-center">
<NavLink
to={joiningRoute}
onClick={onClick}
className="nav-link d-flex align-items-center justify-content-center"
>
<rb.Nav.Item className="d-flex align-items-stretch">
<NavLink to={joiningRoute} onClick={onClick} className="nav-link d-flex align-items-center">
<rb.Navbar.Text className="d-md-none">{t('navbar.joining_in_progress')}</rb.Navbar.Text>
<JoiningIndicator
isOn={true}
Expand All @@ -190,7 +186,7 @@ const TrailingNav = ({ joiningRoute, onClick }: TrailingNavProps) => {
</rb.Nav.Item>
)}
{isDebugFeatureEnabled('fastThemeToggle') && (
<rb.Nav.Item className="d-none d-md-flex align-items-center justify-content-center">
<rb.Nav.Item className="d-none d-md-flex align-items-stretch">
<FastThemeToggle />
</rb.Nav.Item>
)}
Expand Down Expand Up @@ -226,13 +222,13 @@ function FastThemeToggle() {
)

return (
<Sprite
className="cursor-pointer"
<rb.Button
variant="link"
className="unstyled"
onClick={() => setTheme(isLightTheme ? window.JM.THEMES[1] : window.JM.THEMES[0])}
symbol={isLightTheme ? window.JM.THEMES[0] : window.JM.THEMES[1]}
width="30"
height="30"
/>
>
<Sprite symbol={isLightTheme ? window.JM.THEMES[0] : window.JM.THEMES[1]} width="30" height="30" />
</rb.Button>
)
}

Expand Down
1 change: 1 addition & 0 deletions src/components/PaymentConfirmModal.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
color: var(--bs-gray-500);
border: 1px solid var(--bs-gray-500);
border-radius: 50%;
cursor: help;
}
12 changes: 10 additions & 2 deletions src/components/SegmentedTabs.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
}

.segmented-tab input[type='radio'] {
display: none;
appearance: none;
margin: 0;
position: absolute;
opacity: 0;
height: 0;
width: 0;
}

.segmented-tab label {
Expand Down Expand Up @@ -52,7 +57,6 @@
.segmented-tab input[type='radio']:not(:disabled) ~ label {
cursor: pointer;
}

.segmented-tab input[type='radio']:checked:not(:disabled) ~ label {
background-color: var(--bs-gray-100);
box-shadow: 1px 1px 3px 1px rgba(0, 0, 0, 0.1);
Expand All @@ -61,3 +65,7 @@
:root[data-theme='dark'] .segmented-tab input[type='radio']:checked:not(:disabled) ~ label {
background-color: var(--bs-gray-600);
}

.segmented-tab input[type='radio']:focus ~ label {
box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color) !important;
}
27 changes: 14 additions & 13 deletions src/components/SegmentedTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@ interface SegmentedTab {
disabled?: boolean
}

function SegmentedTabFormCheck({ id, name, value, label, disabled, defaultChecked, onChange }: rb.FormCheckProps) {
function SegmentedTabFormCheck({ id, name, value, label, disabled, checked, onChange }: rb.FormCheckProps) {
const _onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
e.stopPropagation()
onChange && onChange(e)
}

return (
<>
<rb.Form.Check
bsPrefix={styles['segmented-tab']}
type="radio"
id={id}
value={value}
name={name}
label={label}
disabled={disabled}
defaultChecked={defaultChecked}
onChange={_onChange}
/>
<div className={styles['segmented-tab']}>
<input
id={id}
name={name}
type="radio"
value={value}
checked={checked}
onChange={_onChange}
disabled={disabled}
/>
<label htmlFor={id}>{label}</label>
</div>
</>
)
}
Expand Down Expand Up @@ -57,7 +58,7 @@ export default function SegmentedTabs({ name, tabs, onChange, initialValue, disa
label={tab.label}
disabled={disabled || tab.disabled}
inline={true}
defaultChecked={initialValue === tab.value}
checked={initialValue === tab.value}
onChange={(e) => _onChange(e, tab)}
/>
)
Expand Down
1 change: 0 additions & 1 deletion src/components/jar_details/JarDetailsOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ const JarDetailsOverlay = (props: JarDetailsOverlayProps) => {
className={`offcanvas-fullscreen ${styles.overlayContainer}`}
show={props.isShown}
onHide={props.onHide}
keyboard={false}
placement="bottom"
>
<rb.Offcanvas.Header>
Expand Down
3 changes: 3 additions & 0 deletions src/components/jars/Jar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,15 @@
}

.selectableJarContainer .selectionCircle {
appearance: none;
height: 1.5rem;
width: 1.5rem;

border-radius: 50%;
display: inline-block;
border: 1px solid var(--bs-body-color);

cursor: pointer;
}

.selectableJarContainer:not(.selectable) .selectionCircle {
Expand Down
15 changes: 13 additions & 2 deletions src/components/jars/Jar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,13 @@ const SelectableJar = ({
>
<Jar index={index} {...jarProps} />
<div className="d-flex justify-content-center align-items-center gap-1 mt-2 position-relative">
<div className={styles.selectionCircle} />
<input
type="radio"
checked={isSelected}
onChange={() => isSelectable && onClick(index)}
className={styles.selectionCircle}
disabled={!isSelectable}
/>
{variant === 'warning' && (
<div className="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-warning text-dark p-0">
<Sprite symbol="warn" width="20" height="20" />
Expand Down Expand Up @@ -206,7 +212,12 @@ const OpenableJar = ({ tooltipText, onClick, ...jarProps }: OpenableJarProps) =>
}}
overlay={(props) => <rb.Tooltip {...props}>{tooltipText}</rb.Tooltip>}
>
<div className={styles.tooltipJarContainer} onClick={onClick}>
<div
tabIndex={0}
className={styles.tooltipJarContainer}
onClick={onClick}
onKeyDown={(e) => e.key === 'Enter' && onClick()}
>
<Jar {...jarProps} isOpen={jarIsOpen} />
</div>
</rb.OverlayTrigger>
Expand Down