-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Link): implement link component (#953)
- Loading branch information
1 parent
ac166db
commit 512bb43
Showing
47 changed files
with
2,593 additions
and
919 deletions.
There are no files selected for viewing
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
144 changes: 0 additions & 144 deletions
144
packages/react/src/components/buttons/abstract-button.tsx
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
packages/react/src/components/buttons/abstract/abstract-button.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,29 @@ | ||
import { forwardRef, PropsWithChildren, Ref } from 'react'; | ||
import { useDeviceContext } from '../../device-context-provider/device-context-provider'; | ||
import { StyledAbstractButton } from './styled'; | ||
import { AbstractButtonProps } from './types'; | ||
|
||
export const AbstractButton = forwardRef<HTMLButtonElement, PropsWithChildren<AbstractButtonProps>>(({ | ||
children, | ||
onClick, | ||
focusable, | ||
...props | ||
}: AbstractButtonProps, ref: Ref<HTMLButtonElement>) => { | ||
const { isMobile } = useDeviceContext(); | ||
|
||
return ( | ||
<StyledAbstractButton | ||
$focusable={focusable} | ||
$isMobile={isMobile} | ||
onClick={onClick} | ||
ref={ref} | ||
tabIndex={focusable === false ? -1 : undefined} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
> | ||
{children} | ||
</StyledAbstractButton> | ||
); | ||
}); | ||
|
||
AbstractButton.displayName = 'AbstractButton'; |
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,70 @@ | ||
import styled, { css, FlattenInterpolation, ThemeProps } from 'styled-components'; | ||
import { ResolvedTheme } from '../../../themes/theme'; | ||
import { focus } from '../../../utils/css-state'; | ||
import { Size } from './types'; | ||
|
||
export interface BaseButtonStyles { | ||
$size?: Size; | ||
$isMobile: boolean; | ||
$focusable?: boolean; | ||
$inverted?: boolean; | ||
} | ||
|
||
function getButtonMinHeight({ $isMobile, $size }: BaseButtonStyles): string { | ||
switch ($size) { | ||
case 'small': | ||
return $isMobile ? 'var(--size-3x)' : 'var(--size-1halfx)'; | ||
case 'medium': | ||
default: | ||
return $isMobile ? 'var(--size-3x)' : 'var(--size-2x)'; | ||
} | ||
} | ||
|
||
function getButtonPadding({ $isMobile, $size }: BaseButtonStyles): string { | ||
switch ($size) { | ||
case 'small': | ||
return $isMobile ? '0 var(--spacing-3x);' : '0 var(--spacing-1halfx);'; | ||
case 'medium': | ||
default: | ||
return $isMobile ? '0 var(--spacing-3x);' : '0 var(--spacing-2x);'; | ||
} | ||
} | ||
|
||
export const getBaseButtonStyles = ({ | ||
$size, | ||
$isMobile, | ||
$focusable, | ||
$inverted, | ||
}: BaseButtonStyles): FlattenInterpolation<ThemeProps<ResolvedTheme>> => css` | ||
align-items: center; | ||
appearance: none; | ||
background: inherit; | ||
border: 1px solid; | ||
border-radius: 1.5rem; | ||
box-sizing: border-box; | ||
color: inherit; | ||
display: inline-flex; | ||
font-family: inherit; | ||
font-size: ${$isMobile ? 0.875 : 0.75}rem; | ||
font-weight: var(--font-bold); | ||
justify-content: center; | ||
letter-spacing: ${$isMobile ? 0.033125 : 0.025}rem; | ||
line-height: ${$isMobile ? 1.5 : 1}rem; | ||
min-height: ${getButtonMinHeight({ $isMobile, $size })}; | ||
min-width: 2rem; | ||
outline: none; | ||
padding: ${getButtonPadding({ $isMobile, $size })}; | ||
text-transform: uppercase; | ||
user-select: none; | ||
${({ theme }) => $focusable !== false && focus({ theme }, { inverted: $inverted })}; | ||
> svg { | ||
height: ${$isMobile ? 'var(--size-1halfx)' : 'var(--size-1x)'}; | ||
width: ${$isMobile ? 'var(--size-1halfx)' : 'var(--size-1x)'}; | ||
} | ||
`; | ||
|
||
export const StyledAbstractButton = styled.button<BaseButtonStyles>` | ||
${getBaseButtonStyles}; | ||
`; |
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,9 @@ | ||
import { ButtonHTMLAttributes } from 'react'; | ||
|
||
export type Size = 'small' | 'medium'; | ||
|
||
export interface AbstractButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
focusable?: boolean; | ||
isMobile: boolean; | ||
size?: Size; | ||
} |
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
Oops, something went wrong.