@loomhq/lens 10.101.3 → 10.102.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.
|
@@ -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,65 @@ 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)} ${u(3)};
|
|
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('medium')};
|
|
148
|
+
transition: 0.6s color;
|
|
149
|
+
white-space: nowrap;
|
|
150
|
+
${props => props.isActive &&
|
|
151
|
+
`background-color: ${getColorValue('background')};
|
|
152
|
+
color: ${getColorValue('primary')};
|
|
153
|
+
`};
|
|
154
|
+
|
|
155
|
+
&:focus,
|
|
156
|
+
&:focus-visible {
|
|
157
|
+
outline: 1px solid transparent;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&:focus-visible {
|
|
161
|
+
${getFocusRing(undefined, 'inset')};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&:hover {
|
|
165
|
+
color: ${getColorValue('primary')};
|
|
166
|
+
transition: 0.3s color;
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
98
169
|
export const Tab = (_a) => {
|
|
99
170
|
var { children, isActive, htmlTag = 'button', icon } = _a, props = __rest(_a, ["children", "isActive", "htmlTag", "icon"]);
|
|
171
|
+
const { isPilledDesign } = React.useContext(TabsContext);
|
|
172
|
+
if (isPilledDesign) {
|
|
173
|
+
return (React.createElement(TabWrapperPilled, Object.assign({ as: htmlTag, isActive: isActive, icon: icon }, props),
|
|
174
|
+
icon && (React.createElement(Container, { htmlTag: "span", paddingRight: children && 'small' },
|
|
175
|
+
React.createElement(Icon, { icon: icon, color: "currentColor", hasWidthOffset: true }))),
|
|
176
|
+
children));
|
|
177
|
+
}
|
|
100
178
|
return (React.createElement(TabWrapper, Object.assign({ as: htmlTag, isActive: isActive, icon: icon }, props),
|
|
101
179
|
icon && (React.createElement(Container, { htmlTag: "span", paddingRight: children && 'small' },
|
|
102
180
|
React.createElement(Icon, { icon: icon, color: "currentColor", hasWidthOffset: true }))),
|
|
103
181
|
children));
|
|
104
182
|
};
|
|
105
183
|
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));
|
|
184
|
+
var { children, scrollOffset, hasFullTabs, isPilledDesign } = _a, props = __rest(_a, ["children", "scrollOffset", "hasFullTabs", "isPilledDesign"]);
|
|
185
|
+
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
186
|
if (scrollOffset) {
|
|
109
187
|
return React.createElement(Wrapper, { scrollOffset: scrollOffset }, tabsContent);
|
|
110
188
|
}
|
|
111
|
-
return tabsContent;
|
|
189
|
+
return (React.createElement(TabsContext.Provider, { value: { isPilledDesign } }, tabsContent));
|
|
112
190
|
};
|
|
113
191
|
export default Tabs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loomhq/lens",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.102.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "next",
|
|
6
6
|
"build:next": "next build",
|
|
@@ -131,5 +131,5 @@
|
|
|
131
131
|
"git add"
|
|
132
132
|
]
|
|
133
133
|
},
|
|
134
|
-
"types": "dist/
|
|
134
|
+
"types": "dist/index.d.ts"
|
|
135
135
|
}
|