@soul-refiner/design-system 0.2.5 → 0.2.7

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.
@@ -6,17 +6,18 @@ export interface TabProps {
6
6
  items: {
7
7
  color?: TabColors;
8
8
  disabled?: boolean;
9
+ href?: string;
9
10
  icon?: React.ReactElement;
10
11
  label: string;
11
12
  }[];
12
- onChange: (index: number) => void;
13
+ onChange?: (index: number) => void;
13
14
  size?: TabSizes;
14
15
  sx?: string;
15
16
  }
16
17
  declare const Tabs: {
17
18
  ({ activeIndex, items, onChange, size, sx, }: TabProps): React.JSX.Element;
18
19
  Item: {
19
- ({ active, color, disabled, icon, label, onClick, size, }: TabsItemProps): React.JSX.Element;
20
+ ({ active, color, disabled, href, icon, label, onClick, size, }: TabsItemProps): React.JSX.Element;
20
21
  displayName: string;
21
22
  };
22
23
  };
@@ -24,9 +25,10 @@ export interface TabsItemProps {
24
25
  active: boolean;
25
26
  color?: TabColors;
26
27
  disabled?: boolean;
28
+ href?: string;
27
29
  icon?: React.ReactElement;
28
30
  label: string;
29
- onClick: () => void;
31
+ onClick?: () => void;
30
32
  size: TabSizes;
31
33
  }
32
34
  export { Tabs };
@@ -46,9 +46,9 @@ const colorLookup = {
46
46
  };
47
47
  const Tabs = ({ activeIndex, items, onChange, size = 'large', sx, }) => {
48
48
  const id = React.useId();
49
- return (React.createElement(Wrapper, { "$sx": sx }, items.map((item, index) => (React.createElement(Item, { active: activeIndex === index, color: item?.color, disabled: item?.disabled, key: id + index.toString(36), icon: item?.icon, label: item.label, onClick: () => onChange(index), size: size })))));
49
+ return (React.createElement(Wrapper, { "$sx": sx }, items.map((item, index) => (React.createElement(Item, { active: activeIndex === index, color: item?.color, disabled: item?.disabled, href: item?.href, icon: item?.icon, key: id + index.toString(36), label: item.label, onClick: () => onChange && onChange(index), size: size })))));
50
50
  };
51
- const Wrapper = styled.ul `
51
+ const Wrapper = styled.div `
52
52
  display: flex;
53
53
  flex-flow: row nowrap;
54
54
  align-items: flex-end;
@@ -59,17 +59,18 @@ const Wrapper = styled.ul `
59
59
 
60
60
  ${({ $sx }) => ($sx ? $sx : '')}
61
61
  `;
62
- const Item = ({ active, color, disabled, icon, label, onClick, size = 'large', }) => {
62
+ const Item = ({ active, color, disabled, href, icon, label, onClick, size = 'large', }) => {
63
+ const isAnchor = !!href;
63
64
  const inputColor = disabled ? 'grey' : color ? color : 'blue';
64
65
  const iconColor = colorLookup[inputColor].icon;
65
66
  const bgColor = colorLookup[inputColor].bg;
66
67
  const fontSize = size === 'large' ? 16 : size === 'medium' ? 14 : 12;
67
68
  const lineHeight = size === 'large' ? 24 : size === 'medium' ? 20 : 16;
68
- return (React.createElement(Li, { "$active": active, "$color": iconColor, "$disabled": disabled, "$hasIcon": !!icon, "$size": size, onClick: !disabled ? onClick : undefined },
69
+ return (React.createElement(Element, { as: isAnchor ? 'a' : 'div', href: href, onClick: !disabled && onClick ? onClick : undefined, "$active": active, "$color": iconColor, "$disabled": disabled, "$hasIcon": !!icon, "$size": size },
69
70
  icon && React.createElement(IconWrapper, { "$bg": bgColor }, icon),
70
71
  React.createElement(P, { "$fontSize": fontSize, "$lineHeight": lineHeight, "$semiBold": true }, label)));
71
72
  };
72
- const Li = styled.li `
73
+ const Element = styled.div `
73
74
  position: relative;
74
75
  display: flex;
75
76
  align-items: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {