Skip to content
Open
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
18 changes: 16 additions & 2 deletions src/components/Back/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,21 @@ const Back = (props: BackProps) => {
return (
<Row className="h-center" style={{ padding: '12px 0px' }}>
<Row className="h-center">
<Row className="h-center" style={{ height: '36px' }} onClick={onClick}>
<button
type="button"
onClick={onClick}
aria-label={heading ? `Back to ${heading}` : 'Back'}
style={{
background: 'transparent',
border: 'none',
padding: 0,
margin: 0,
height: '36px',
display: 'flex',
alignItems: 'center',
cursor: 'pointer',
}}
>
<svg width="32" height="12" viewBox="0 0 32 12" fill="none">
<path
d="M31 6L0.999999 6"
Expand All @@ -36,7 +50,7 @@ const Back = (props: BackProps) => {
strokeWidth="1.5"
/>
</svg>
</Row>
</button>
<VerticalSpacer n={4} />
{heading ? (
<Typography {...textStyle} color={color ?? mainColors.white}>
Expand Down
16 changes: 13 additions & 3 deletions src/components/Checkbox/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,23 @@ export const CheckboxLabel = styled.label`
user-select: none;
-webkit-tap-highlight-color: transparent;

/* Hide the browser's default checkbox */
/* Keep the native input present and focusable but visually hidden */
input {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
height: ${BOX_SIZE}px;
width: ${BOX_SIZE}px;
left: 0;
top: 0;
margin: 0;
z-index: 3;
}

/* Visible focus state for keyboard users */
input:focus + div .checkmark {
outline: none;
box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.25);
}
`;

Expand Down
7 changes: 6 additions & 1 deletion src/components/Dropdown/styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from 'styled-components';
import { DropdownConfig } from './types';

export const DropdownContainer = styled.div`
export const DropdownContainer = styled.button`
display: inline-flex;
align-items: center;
justify-content: center;
Expand All @@ -10,6 +10,11 @@ export const DropdownContainer = styled.div`
--webkit-user-select: none;
padding: 10px 15px;
border: ${({ border }: DropdownConfig) => `1px solid ${border}`};
background: transparent;
margin: 0;
padding: 10px 15px;
outline: none;
cursor: pointer;
&.no-label {
width: 22px;
min-width: 22px;
Expand Down
23 changes: 18 additions & 5 deletions src/components/Helpers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,22 @@ export const Pointer = ({
</svg>
);

export const Cross = ({ color = mainColors.white, onClick }: CrossProps) => (
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" onClick={onClick}>
<path d="M2 10L6 6L2 2" stroke={color} strokeWidth="1.5" strokeLinecap="square" />
<path d="M10 10L6 6L10 2" stroke={color} strokeWidth="1.5" strokeLinecap="square" />
</svg>
export const Cross = ({ color = mainColors.white, onClick, ariaLabel = 'close' }: CrossProps) => (
<button
type="button"
onClick={onClick}
aria-label={ariaLabel}
style={{
background: 'transparent',
border: 'none',
padding: 0,
margin: 0,
cursor: 'pointer',
}}
>
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden>
<path d="M2 10L6 6L2 2" stroke={color} strokeWidth="1.5" strokeLinecap="square" />
<path d="M10 10L6 6L10 2" stroke={color} strokeWidth="1.5" strokeLinecap="square" />
</svg>
</button>
);
1 change: 1 addition & 0 deletions src/components/Helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export type PointerProps = ChevronProps & {
export interface CrossProps {
color: string;
onClick: () => void;
ariaLabel?: string;
}
1 change: 0 additions & 1 deletion src/components/Radio/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const Radio = (props: RadioProps) => {

const RadioStyledButton = () => (
<StyledRadio
onClick={() => radioRef?.current?.click()}
colorConfig={
isEmpty(colorConfig) ? defaultColorConfig : colorConfig ?? defaultColorConfig
}
Expand Down
9 changes: 7 additions & 2 deletions src/components/Radio/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RadioContainerColorConfig, StyledRadioProps } from './types';

const RADIO_SIZE = 20;

export const StyledRadio = styled.div<StyledRadioProps>`
export const StyledRadio = styled.label<StyledRadioProps>`
display: block;
position: relative;
cursor: pointer;
Expand All @@ -16,12 +16,17 @@ export const StyledRadio = styled.div<StyledRadioProps>`
width: ${RADIO_SIZE}px;
height: ${RADIO_SIZE}px;

/* Hide the browser's default radio button */
/* Keep native radio present & focusable but visually hidden */
input {
position: absolute;
opacity: 0;
cursor: pointer;
left: 0;
top: 0;
width: 100%;
height: 100%;
margin: 0;
z-index: 3;
}

/* Create a custom radio button */
Expand Down
11 changes: 3 additions & 8 deletions src/components/SearchBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,15 @@ const SearchBar = (props: SearchBarProps) => {
: inputColorConfig ?? defaultInputFieldColorConfig;

return (
<SearchBarContainer
{...searchColorConfig}
className={isActive ? 'active' : ''}
onClick={() => setIsActive(true)}
onBlur={() => {
setIsActive(false);
}}
>
<SearchBarContainer {...searchColorConfig} className={isActive ? 'active' : ''}>
{iconUrl ? <img src={iconUrl} alt="search" className="icon" /> : null}
<div className="input">
<form onSubmit={handleSubmit} style={{ margin: '0', padding: '0' }}>
<InputField
inputRef={inputRef}
autoFocus={isActive}
onFocus={() => setIsActive(true)}
onBlur={() => setIsActive(false)}
textStyle={{
input: textStyle,
label: typographyGuide.inputFields.label,
Expand Down
10 changes: 10 additions & 0 deletions src/components/Toast/components/ToastPortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,22 @@ export const Toast = (props: ToastProps) => {

return (
<ToastItem
as={dismissOnClick ? 'button' : 'div'}
type={dismissOnClick ? 'button' : undefined}
tabIndex={dismissOnClick ? 0 : undefined}
background={colorConfig.background}
autoCloseTime={autoCloseTime}
fullWidth={fullWidth}
onClick={() => {
if (dismissOnClick && id) removeToast?.(id);
}}
onKeyDown={(e: React.KeyboardEvent) => {
if (!dismissOnClick) return;
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
if (id) removeToast?.(id);
}
}}
>
<Column>
<Typography {...textStyle.heading} color={colorConfig.color}>
Expand Down
1 change: 0 additions & 1 deletion src/components/Toggle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const Toggle = (props: ToggleProps) => {
colorConfig={
isEmpty(colorConfig) ? defaultColorConfig : colorConfig ?? defaultColorConfig
}
onClick={() => toggleRef?.current?.click()}
>
<input type="checkbox" ref={toggleRef} checked={isChecked} onChange={handleChange} />
<div className="mark" />
Expand Down
10 changes: 7 additions & 3 deletions src/components/Toggle/styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from 'styled-components';
import { StyledToggleProps } from './types';

export const ToggleBtn = styled.div<StyledToggleProps>`
export const ToggleBtn = styled.label<StyledToggleProps>`
width: 40px;
height: 22px;
border: 1px solid ${(props) => props.colorConfig.on.switchBorder};
Expand All @@ -22,9 +22,13 @@ export const ToggleBtn = styled.div<StyledToggleProps>`

input {
opacity: 0;
width: 0;
height: 0;
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
margin: 0;
z-index: 3;
}

/* Create a custom toggle box */
Expand Down