@coldsurf/ocean-road 1.13.7 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "imcoldsurf@gmail.com",
6
6
  "url": "https://coldsurf.io"
7
7
  },
8
- "version": "1.13.7",
8
+ "version": "1.14.0",
9
9
  "bugs": {
10
10
  "url": "https://github.com/coldsurfers/ocean-road/issues"
11
11
  },
@@ -1,17 +1,51 @@
1
1
  import styled from '@emotion/styled';
2
+ import { semantics, typography } from '../../tokens';
2
3
 
3
- export const StyledTextContainer = styled.span<{ numberOfLines?: number }>`
4
+ type TextVariant = 'heading1' | 'heading2' | 'heading3' | 'body1' | 'body2' | 'caption' | 'label';
5
+
6
+ type TextSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
7
+
8
+ type TextWeight = 'regular' | 'medium' | 'semibold' | 'bold';
9
+
10
+ export type StyledTextContainerProps = {
11
+ numberOfLines?: number;
12
+ variant?: TextVariant;
13
+ size?: TextSize;
14
+ weight?: TextWeight;
15
+ };
16
+
17
+ export const StyledTextContainer = styled.span<StyledTextContainerProps>`
4
18
  white-space: pre-wrap;
5
19
  line-height: 1.25;
6
20
 
21
+ ${({ variant }) =>
22
+ variant &&
23
+ `
24
+ font-size: ${semantics.typography[variant].fontSize};
25
+ font-weight: ${semantics.typography[variant].fontWeight};
26
+ line-height: ${semantics.typography[variant].lineHeight};
27
+ `}
28
+
29
+ ${({ size }) =>
30
+ size &&
31
+ `
32
+ font-size: ${typography.fontSize[size]};
33
+ `}
34
+
35
+ ${({ weight }) =>
36
+ weight &&
37
+ `
38
+ font-weight: ${typography.fontWeight[weight]};
39
+ `}
40
+
7
41
  ${({ numberOfLines }) =>
8
42
  numberOfLines &&
9
43
  `
10
- display: -webkit-box;
11
- overflow: hidden;
12
- text-overflow: ellipsis;
13
- -webkit-line-clamp: ${numberOfLines};
14
- -webkit-box-orient: vertical;
15
- word-break: break-all;
44
+ display: -webkit-box;
45
+ overflow: hidden;
46
+ text-overflow: ellipsis;
47
+ -webkit-line-clamp: ${numberOfLines};
48
+ -webkit-box-orient: vertical;
49
+ word-break: break-all;
16
50
  `}
17
51
  `;
@@ -5,7 +5,7 @@ import {
5
5
  type PropsWithChildren,
6
6
  forwardRef,
7
7
  } from 'react';
8
- import { StyledTextContainer } from './text.styled';
8
+ import { StyledTextContainer, type StyledTextContainerProps } from './text.styled';
9
9
 
10
10
  type TextProps = PropsWithChildren<
11
11
  ComponentPropsWithRef<'span'> & {
@@ -13,16 +13,19 @@ type TextProps = PropsWithChildren<
13
13
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
14
14
  as?: ElementType<any, keyof JSX.IntrinsicElements>;
15
15
  numberOfLines?: number;
16
- }
16
+ } & Pick<StyledTextContainerProps, 'variant' | 'size' | 'weight'>
17
17
  >;
18
18
 
19
19
  export const Text = forwardRef<HTMLSpanElement, TextProps>(
20
- ({ children, style, as, numberOfLines, ...otherProps }, ref) => {
20
+ ({ children, style, as, numberOfLines, variant, size, weight, ...otherProps }, ref) => {
21
21
  return (
22
22
  <StyledTextContainer
23
23
  ref={ref}
24
24
  as={as}
25
25
  numberOfLines={numberOfLines}
26
+ variant={variant}
27
+ size={size}
28
+ weight={weight}
26
29
  style={{
27
30
  ...style,
28
31
  }}