@loomhq/lens 10.101.4 → 10.102.1
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.
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare const TabWrapper: import("@emotion/styled-base").StyledComponent<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, TabWrapperProps, object>;
|
|
3
3
|
export declare const Tab: ({ children, isActive, htmlTag, icon, ...props }: TabProps & React.ComponentProps<typeof TabWrapper>) => JSX.Element;
|
|
4
|
-
declare const Tabs: ({ children, scrollOffset, hasFullTabs, ...props }: TabsProps) => JSX.Element;
|
|
4
|
+
declare const Tabs: ({ children, scrollOffset, hasFullTabs, isPilledDesign, ...props }: TabsProps) => JSX.Element;
|
|
5
5
|
type TabsProps = {
|
|
6
6
|
scrollOffset?: number | string;
|
|
7
7
|
hasFullTabs?: boolean;
|
|
8
8
|
children?: React.ReactNode;
|
|
9
|
+
isPilledDesign?: boolean;
|
|
9
10
|
};
|
|
10
11
|
type TabProps = {
|
|
11
12
|
isActive?: boolean;
|
|
12
13
|
icon?: React.ReactNode;
|
|
13
14
|
children?: React.ReactNode;
|
|
14
15
|
htmlTag?: 'a' | 'button' | 'span';
|
|
16
|
+
isPilledDesign?: boolean;
|
|
15
17
|
};
|
|
16
18
|
type TabWrapperProps = {
|
|
17
19
|
isActive?: boolean;
|
|
@@ -14,6 +14,7 @@ import Container from '../container/container';
|
|
|
14
14
|
import Icon from '../icon/icon';
|
|
15
15
|
import React from 'react';
|
|
16
16
|
import styled from '@emotion/styled';
|
|
17
|
+
const TabsContext = React.createContext({});
|
|
17
18
|
const negativeScrollOffset = scrollOffset => `calc(-1 * ${getSizeValue(scrollOffset)})`;
|
|
18
19
|
const Wrapper = styled.div `
|
|
19
20
|
${props => props.scrollOffset &&
|
|
@@ -27,6 +28,7 @@ const TabsNav = styled.nav `
|
|
|
27
28
|
overflow: auto;
|
|
28
29
|
-ms-overflow-style: none;
|
|
29
30
|
scrollbar-width: none;
|
|
31
|
+
|
|
30
32
|
${props => props.scrollOffset && getSize('padding-left', props.scrollOffset)};
|
|
31
33
|
|
|
32
34
|
&::-webkit-scrollbar {
|
|
@@ -47,6 +49,36 @@ const TabsNav = styled.nav `
|
|
|
47
49
|
${props => props.scrollOffset && getSize('width', props.scrollOffset)};
|
|
48
50
|
}
|
|
49
51
|
`;
|
|
52
|
+
const TabsNavPilled = styled.nav `
|
|
53
|
+
${getRadius('full')};
|
|
54
|
+
background-color: var(--lns-color-backgroundSecondary);
|
|
55
|
+
|
|
56
|
+
padding: var(--lns-space-xsmall);
|
|
57
|
+
|
|
58
|
+
display: flex;
|
|
59
|
+
overflow: auto;
|
|
60
|
+
-ms-overflow-style: none;
|
|
61
|
+
scrollbar-width: none;
|
|
62
|
+
${props => props.scrollOffset && getSize('padding-left', props.scrollOffset)};
|
|
63
|
+
|
|
64
|
+
&::-webkit-scrollbar {
|
|
65
|
+
display: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
& > * {
|
|
69
|
+
flex: 1 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
& > * + * {
|
|
73
|
+
margin-left: ${u(2)};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&:after {
|
|
77
|
+
content: '';
|
|
78
|
+
flex-shrink: 0;
|
|
79
|
+
${props => props.scrollOffset && getSize('width', props.scrollOffset)};
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
50
82
|
const TabWrapper = styled.button `
|
|
51
83
|
appearance: none;
|
|
52
84
|
font: inherit;
|
|
@@ -95,19 +127,66 @@ const TabWrapper = styled.button `
|
|
|
95
127
|
${props => props.isActive && `background-color: ${getColorValue('primary')}`};
|
|
96
128
|
}
|
|
97
129
|
`;
|
|
130
|
+
const TabWrapperPilled = styled.button `
|
|
131
|
+
padding: ${u(1)} 0;
|
|
132
|
+
|
|
133
|
+
appearance: none;
|
|
134
|
+
font: inherit;
|
|
135
|
+
background: transparent;
|
|
136
|
+
border: none;
|
|
137
|
+
${getRadius('full')};
|
|
138
|
+
cursor: pointer;
|
|
139
|
+
display: inline-flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
justify-content: center;
|
|
142
|
+
vertical-align: middle;
|
|
143
|
+
position: relative;
|
|
144
|
+
color: inherit;
|
|
145
|
+
text-decoration: none;
|
|
146
|
+
flex-shrink: 0;
|
|
147
|
+
${getFontWeight('bold')};
|
|
148
|
+
|
|
149
|
+
transition: 0.6s color;
|
|
150
|
+
white-space: nowrap;
|
|
151
|
+
${props => props.isActive &&
|
|
152
|
+
`background-color: ${getColorValue('background')};
|
|
153
|
+
color: ${getColorValue('primary')};
|
|
154
|
+
`};
|
|
155
|
+
|
|
156
|
+
&:focus,
|
|
157
|
+
&:focus-visible {
|
|
158
|
+
outline: 1px solid transparent;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&:focus-visible {
|
|
162
|
+
${getFocusRing(undefined, 'inset')};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&:hover {
|
|
166
|
+
color: ${getColorValue('primary')};
|
|
167
|
+
transition: 0.3s color;
|
|
168
|
+
}
|
|
169
|
+
`;
|
|
98
170
|
export const Tab = (_a) => {
|
|
99
171
|
var { children, isActive, htmlTag = 'button', icon } = _a, props = __rest(_a, ["children", "isActive", "htmlTag", "icon"]);
|
|
172
|
+
const { isPilledDesign } = React.useContext(TabsContext);
|
|
173
|
+
if (isPilledDesign) {
|
|
174
|
+
return (React.createElement(TabWrapperPilled, Object.assign({ as: htmlTag, isActive: isActive, icon: icon }, props),
|
|
175
|
+
icon && (React.createElement(Container, { htmlTag: "span", paddingRight: children && 'small' },
|
|
176
|
+
React.createElement(Icon, { icon: icon, color: "currentColor", hasWidthOffset: true }))),
|
|
177
|
+
children));
|
|
178
|
+
}
|
|
100
179
|
return (React.createElement(TabWrapper, Object.assign({ as: htmlTag, isActive: isActive, icon: icon }, props),
|
|
101
180
|
icon && (React.createElement(Container, { htmlTag: "span", paddingRight: children && 'small' },
|
|
102
181
|
React.createElement(Icon, { icon: icon, color: "currentColor", hasWidthOffset: true }))),
|
|
103
182
|
children));
|
|
104
183
|
};
|
|
105
184
|
const Tabs = (_a) => {
|
|
106
|
-
var { children, scrollOffset, hasFullTabs } = _a, props = __rest(_a, ["children", "scrollOffset", "hasFullTabs"]);
|
|
107
|
-
const tabsContent = (React.createElement(TabsNav, Object.assign({ hasFullTabs: hasFullTabs, scrollOffset: scrollOffset }, props), children));
|
|
185
|
+
var { children, scrollOffset, hasFullTabs, isPilledDesign } = _a, props = __rest(_a, ["children", "scrollOffset", "hasFullTabs", "isPilledDesign"]);
|
|
186
|
+
const tabsContent = isPilledDesign ? (React.createElement(TabsNavPilled, Object.assign({ hasFullTabs: hasFullTabs, scrollOffset: scrollOffset }, props), children)) : (React.createElement(TabsNav, Object.assign({ hasFullTabs: hasFullTabs, scrollOffset: scrollOffset }, props), children));
|
|
108
187
|
if (scrollOffset) {
|
|
109
188
|
return React.createElement(Wrapper, { scrollOffset: scrollOffset }, tabsContent);
|
|
110
189
|
}
|
|
111
|
-
return tabsContent;
|
|
190
|
+
return (React.createElement(TabsContext.Provider, { value: { isPilledDesign } }, tabsContent));
|
|
112
191
|
};
|
|
113
192
|
export default Tabs;
|