@soul-refiner/design-system 0.2.130 → 0.2.131
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,9 +6,9 @@ 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
|
-
onClick: () => void;
|
|
12
12
|
}[];
|
|
13
13
|
onChange?: (index: number) => void;
|
|
14
14
|
size?: TabSizes;
|
|
@@ -17,7 +17,7 @@ export interface TabProps {
|
|
|
17
17
|
declare const Tabs: {
|
|
18
18
|
({ activeIndex, items, onChange, size, sx, }: TabProps): React.JSX.Element;
|
|
19
19
|
Item: {
|
|
20
|
-
({ active, color, disabled, icon, label, onClick, size, }: TabsItemProps): React.JSX.Element;
|
|
20
|
+
({ active, color, disabled, href, icon, label, onClick, size, }: TabsItemProps): React.JSX.Element;
|
|
21
21
|
displayName: string;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
@@ -25,6 +25,7 @@ export interface TabsItemProps {
|
|
|
25
25
|
active: boolean;
|
|
26
26
|
color?: TabColors;
|
|
27
27
|
disabled?: boolean;
|
|
28
|
+
href?: string;
|
|
28
29
|
icon?: React.ReactElement;
|
|
29
30
|
label: string;
|
|
30
31
|
onClick?: () => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
+
import Link from 'next/link';
|
|
4
5
|
import { P } from '../../';
|
|
5
6
|
const colorLookup = {
|
|
6
7
|
blue: {
|
|
@@ -46,10 +47,7 @@ const colorLookup = {
|
|
|
46
47
|
};
|
|
47
48
|
const Tabs = ({ activeIndex, items, onChange, size = 'large', sx, }) => {
|
|
48
49
|
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, icon: item?.icon, key: id + index.toString(36), label: item.label, onClick: () =>
|
|
50
|
-
item.onClick();
|
|
51
|
-
onChange && onChange(index);
|
|
52
|
-
}, size: size })))));
|
|
50
|
+
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 })))));
|
|
53
51
|
};
|
|
54
52
|
const Wrapper = styled.div `
|
|
55
53
|
display: flex;
|
|
@@ -66,17 +64,17 @@ const Wrapper = styled.div `
|
|
|
66
64
|
|
|
67
65
|
${({ $sx }) => ($sx ? $sx : '')}
|
|
68
66
|
`;
|
|
69
|
-
const Item = ({ active, color, disabled, icon, label, onClick, size = 'large', }) => {
|
|
67
|
+
const Item = ({ active, color, disabled, href, icon, label, onClick, size = 'large', }) => {
|
|
70
68
|
const inputColor = disabled ? 'grey' : color ? color : 'blue';
|
|
71
69
|
const iconColor = colorLookup[inputColor].icon;
|
|
72
70
|
const bgColor = colorLookup[inputColor].bg;
|
|
73
71
|
const fontSize = size === 'large' ? 16 : size === 'medium' ? 14 : 12;
|
|
74
72
|
const lineHeight = size === 'large' ? 24 : size === 'medium' ? 20 : 16;
|
|
75
|
-
return (React.createElement(Element, {
|
|
73
|
+
return (React.createElement(Element, { onClick: !disabled && onClick ? onClick : undefined, href: href || '#', scroll: false, "$active": active, "$color": iconColor, "$disabled": disabled, "$hasIcon": !!icon, "$size": size },
|
|
76
74
|
icon && React.createElement(IconWrapper, { "$bg": bgColor }, icon),
|
|
77
75
|
React.createElement(P, { "$fontSize": fontSize, "$lineHeight": lineHeight, "$semiBold": true }, label)));
|
|
78
76
|
};
|
|
79
|
-
const Element = styled
|
|
77
|
+
const Element = styled(Link) `
|
|
80
78
|
position: relative;
|
|
81
79
|
display: flex;
|
|
82
80
|
align-items: center;
|