|
1 | | -import { Badge, descriptors, localizationKeys } from '../customizables'; |
2 | | -import type { InternalTheme, PropsOfComponent, ThemableCssProp } from '../styledSystem'; |
| 1 | +import { descriptors, localizationKeys, Span } from '../customizables'; |
| 2 | +import { common, type PropsOfComponent } from '../styledSystem'; |
3 | 3 |
|
4 | | -const overlayStyles = (t: InternalTheme): ThemableCssProp => [ |
5 | | - { |
6 | | - background: `linear-gradient(${t.colors.$borderAlpha25}, ${t.colors.$borderAlpha25}),${t.colors.$colorBackground}`, |
7 | | - borderColor: t.colors.$colorForeground, |
8 | | - boxShadow: 'none', |
9 | | - outline: `${t.space.$px} solid ${t.colors.$colorBackground}`, |
10 | | - pointerEvents: 'none', |
11 | | - position: 'absolute', |
12 | | - right: `calc(${t.space.$2x5} * -1)`, |
13 | | - top: '-35%', |
14 | | - ':after': { |
15 | | - border: `${t.space.$px} solid ${t.colors.$borderAlpha150}`, |
16 | | - borderRadius: t.radii.$lg, |
17 | | - content: '""', |
18 | | - display: 'block', |
19 | | - height: '100%', |
20 | | - inset: 0, |
21 | | - padding: t.space.$px, |
22 | | - position: 'absolute', |
23 | | - width: '100%', |
24 | | - }, |
25 | | - }, |
26 | | -]; |
27 | | - |
28 | | -export type LastAuthenticationStrategyBadgeProps = PropsOfComponent<typeof Badge> & { overlay?: boolean }; |
| 4 | +export type LastAuthenticationStrategyBadgeProps = PropsOfComponent<typeof Span> & { overlay?: boolean }; |
29 | 5 | export const LastAuthenticationStrategyBadge = ({ |
30 | 6 | sx, |
31 | 7 | overlay, |
32 | 8 | ...props |
33 | | -}: LastAuthenticationStrategyBadgeProps): JSX.Element => ( |
34 | | - <Badge |
35 | | - {...props} |
36 | | - elementDescriptor={descriptors.lastAuthenticationStrategyBadge} |
37 | | - localizationKey={localizationKeys('lastAuthenticationStrategy')} |
38 | | - sx={[ |
39 | | - t => ({ |
40 | | - background: t.colors.$borderAlpha25, |
41 | | - borderRadius: t.radii.$lg, |
42 | | - }), |
43 | | - overlay && overlayStyles, |
44 | | - ...(Array.isArray(sx) ? sx : sx ? [sx] : []), |
45 | | - ]} |
46 | | - /> |
47 | | -); |
| 9 | +}: LastAuthenticationStrategyBadgeProps): JSX.Element => { |
| 10 | + return ( |
| 11 | + <Span |
| 12 | + {...props} |
| 13 | + elementDescriptor={descriptors.lastAuthenticationStrategyBadge} |
| 14 | + localizationKey={localizationKeys('lastAuthenticationStrategy')} |
| 15 | + sx={[ |
| 16 | + t => ({ |
| 17 | + ...common.textVariants(t).caption, |
| 18 | + background: `linear-gradient(${t.colors.$borderAlpha25}, transparent), ${t.colors.$colorBackground}`, |
| 19 | + border: `${t.space.$px} solid ${t.colors.$borderAlpha150}`, |
| 20 | + borderRadius: t.radii.$lg, |
| 21 | + color: t.colors.$colorMutedForeground, |
| 22 | + height: t.space.$4x5, |
| 23 | + paddingInline: t.space.$1x5, |
| 24 | + whiteSpace: 'nowrap', |
| 25 | + boxShadow: `0 0 0 1px ${t.colors.$colorBackground}`, |
| 26 | + ...(overlay && { |
| 27 | + position: 'absolute', |
| 28 | + right: -1, |
| 29 | + top: -1, |
| 30 | + transform: `translate(${t.space.$2x5}, -50%)`, |
| 31 | + pointerEvents: 'none', |
| 32 | + }), |
| 33 | + }), |
| 34 | + sx, |
| 35 | + ]} |
| 36 | + /> |
| 37 | + ); |
| 38 | +}; |
0 commit comments