Skip to content

Commit cd18e78

Browse files
Merge pull request #65 from vtexdocs/feat/input
feat: input
2 parents 4b010bd + 583bfc8 commit cd18e78

File tree

8 files changed

+167
-17
lines changed

8 files changed

+167
-17
lines changed

dist/index.d.mts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ type Section = {
9191
Icon: (props: IconProps) => JSX.Element;
9292
isExternalLink?: boolean;
9393
};
94+
type IconComponent = (props: IconProps) => JSX.Element;
95+
96+
interface InputProps {
97+
value: string;
98+
Icon?: IconComponent;
99+
placeholder?: string;
100+
onChange: (value: string) => void;
101+
}
102+
declare const Input: ({ value, onChange, placeholder, Icon }: InputProps) => react_jsx_runtime.JSX.Element;
94103

95104
interface Props extends Partial<ContextType> {
96105
children: ReactNode;
@@ -153,4 +162,4 @@ interface AlgoliaConfig {
153162
}
154163
declare const createAlgoliaClient: (config: AlgoliaConfig) => void;
155164

156-
export { CookieBar, CopyLinkButton, FeedbackSection, HamburgerMenu, type Item, LibraryContext, LibraryContextProvider, MarkdownRenderer, Search, createAlgoliaClient as SearchConfig, SearchInput, ShareButton, Sidebar, TableOfContents };
165+
export { CookieBar, CopyLinkButton, FeedbackSection, HamburgerMenu, Input, type Item, LibraryContext, LibraryContextProvider, MarkdownRenderer, Search, createAlgoliaClient as SearchConfig, SearchInput, ShareButton, Sidebar, TableOfContents };

dist/index.mjs

Lines changed: 78 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5903,10 +5903,10 @@ var IconsMap = [
59035903
}
59045904
];
59055905
var getIcon = (name) => {
5906-
return IconsMap.find((icon3) => icon3.name === name)?.Icon;
5906+
return IconsMap.find((icon4) => icon4.name === name)?.Icon;
59075907
};
5908-
var OverviewCard = ({ icon: icon3, link: link2, children }) => {
5909-
const Icon32 = getIcon(icon3);
5908+
var OverviewCard = ({ icon: icon4, link: link2, children }) => {
5909+
const Icon32 = getIcon(icon4);
59105910
return /* @__PURE__ */ jsx2(Link, { href: link2, children: /* @__PURE__ */ jsxs2(Flex, { sx: styles_default.overviewCard, children: [
59115911
Icon32 && /* @__PURE__ */ jsx2(Icon32, { sx: styles_default.overviewIcon }),
59125912
/* @__PURE__ */ jsx2(Box, { children })
@@ -6593,8 +6593,8 @@ var ObservableHeading = ({
65936593
}
65946594
);
65956595
};
6596-
var Callout = ({ node, icon: icon3, ...props }) => {
6597-
const blockquoteType = icon3 ? icon3 : "info";
6596+
var Callout = ({ node, icon: icon4, ...props }) => {
6597+
const blockquoteType = icon4 ? icon4 : "info";
65986598
return /* @__PURE__ */ jsx9(
65996599
"blockquote",
66006600
{
@@ -7255,7 +7255,7 @@ import { useRouter as useRouter2 } from "next/router.js";
72557255
import { useEffect as useEffect7 } from "react";
72567256
var getIcon2 = (doc, sections) => {
72577257
for (const section of sections) {
7258-
return section.find((icon3) => icon3.title === doc)?.Icon;
7258+
return section.find((icon4) => icon4.title === doc)?.Icon;
72597259
}
72607260
};
72617261
var updateOpenPage = ({
@@ -7812,17 +7812,17 @@ var styles_default12 = {
78127812
};
78137813

78147814
// src/components/sidebar-elements/functions.tsx
7815-
var styleByLevelNormal = (level, icon3) => {
7816-
const ml = 8 + (icon3 ? (level - 1) * 20 + 6 : (level - 1) * 20 + 14);
7817-
const borderLeft = icon3 ? "none" : level >= 2 ? "1px solid #E7E9EE" : "";
7815+
var styleByLevelNormal = (level, icon4) => {
7816+
const ml = 8 + (icon4 ? (level - 1) * 20 + 6 : (level - 1) * 20 + 14);
7817+
const borderLeft = icon4 ? "none" : level >= 2 ? "1px solid #E7E9EE" : "";
78187818
const normal = {
78197819
marginLeft: `${ml}px`,
78207820
borderLeft
78217821
};
78227822
return normal;
78237823
};
7824-
var textStyle = (active, icon3) => {
7825-
const ml = icon3 ? "4px" : "16px";
7824+
var textStyle = (active, icon4) => {
7825+
const ml = icon4 ? "4px" : "16px";
78267826
if (active) {
78277827
const textStyleActive = {
78287828
...styles_default12.elementActive,
@@ -9620,8 +9620,6 @@ import { useContext as useContext12, useRef as useRef10, useState as useState12
96209620
// src/lib/feedback-section/styles.ts
96219621
var container5 = ({ small } = {}) => ({
96229622
width: "100%",
9623-
paddingBottom: "16px",
9624-
borderBottom: small ? "none" : ["none", "1px solid #E7E9EE"],
96259623
flexDirection: small ? "column" : ["column", "row"],
96269624
alignItems: small ? "flex-start" : "center",
96279625
alignContent: ["initial", "space-between"],
@@ -11311,11 +11309,78 @@ var CopyLinkButton = () => {
1131111309
return /* @__PURE__ */ jsx64(tooltip_default, { label: tooltipText, placement: "bottom", children: /* @__PURE__ */ jsx64(Button8, { onClick: handleCopy, sx: styles_default26.copyLinkButton, children: /* @__PURE__ */ jsx64(copy_icon_default, { sx: styles_default26.copyIcon, size: 16 }) }) });
1131211310
};
1131311311
var copy_link_button_default = CopyLinkButton;
11312+
11313+
// src/components/input/index.tsx
11314+
import { useState as useState17, useEffect as useEffect13 } from "react";
11315+
11316+
// src/components/input/styles.ts
11317+
var input = {
11318+
background: "none",
11319+
border: "#F4F4F4",
11320+
color: "#545454",
11321+
fontSize: ["14px"],
11322+
width: "100%",
11323+
transition: "flex 0.3s",
11324+
outline: "none"
11325+
};
11326+
var icon3 = {
11327+
minWidth: "16px",
11328+
minHeight: "16px",
11329+
width: "16px",
11330+
mr: "8px",
11331+
flex: 0,
11332+
maxWidth: "fit-content"
11333+
};
11334+
var container11 = {
11335+
paddingLeft: "12px",
11336+
alignItems: "center",
11337+
justifyContent: "center",
11338+
background: "#F4F4F4",
11339+
width: "100%",
11340+
height: "40px",
11341+
borderRadius: "4px",
11342+
transition: "all 0.3s ease-out",
11343+
cursor: "pointer",
11344+
border: "1px solid #F4F4F4",
11345+
":hover": {
11346+
transition: "all 0.3s ease-out",
11347+
border: "1px solid #3B3B3B"
11348+
}
11349+
};
11350+
var styles_default27 = { container: container11, input, icon: icon3 };
11351+
11352+
// src/components/input/index.tsx
11353+
import { Flex as Flex23 } from "@vtex/brand-ui";
11354+
import { jsx as jsx65, jsxs as jsxs52 } from "react/jsx-runtime";
11355+
var Input = ({ value, onChange, placeholder = "", Icon: Icon32 }) => {
11356+
const [inputValue, setInputValue] = useState17(value ?? "");
11357+
useEffect13(() => {
11358+
if (inputValue !== value)
11359+
setInputValue(value);
11360+
}, [value]);
11361+
return /* @__PURE__ */ jsxs52(Flex23, { sx: styles_default27.container, children: [
11362+
Icon32 && /* @__PURE__ */ jsx65(Icon32, { sx: styles_default27.icon }),
11363+
/* @__PURE__ */ jsx65(
11364+
"input",
11365+
{
11366+
style: styles_default27.input,
11367+
value: inputValue,
11368+
placeholder,
11369+
onChange: (e) => {
11370+
setInputValue(e.currentTarget.value);
11371+
onChange(e.currentTarget.value);
11372+
}
11373+
}
11374+
)
11375+
] });
11376+
};
11377+
var input_default = Input;
1131411378
export {
1131511379
cookie_bar_default as CookieBar,
1131611380
copy_link_button_default as CopyLinkButton,
1131711381
feedback_section_default as FeedbackSection,
1131811382
hamburger_menu_default as HamburgerMenu,
11383+
input_default as Input,
1131911384
LibraryContext,
1132011385
libraryContext_default as LibraryContextProvider,
1132111386
MarkdownRenderer_default as MarkdownRenderer,

dist/index.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/input/index.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { useState, useEffect } from 'react'
2+
import styles from './styles'
3+
import { Flex } from '@vtex/brand-ui'
4+
import { IconComponent } from 'utils/typings/types'
5+
6+
interface InputProps {
7+
value: string
8+
Icon?: IconComponent
9+
placeholder?: string
10+
onChange: (value: string) => void
11+
}
12+
13+
const Input = ({ value, onChange, placeholder = '', Icon }: InputProps) => {
14+
const [inputValue, setInputValue] = useState(value ?? '')
15+
16+
useEffect(() => {
17+
if (inputValue !== value) setInputValue(value)
18+
}, [value])
19+
20+
return (
21+
<Flex sx={styles.container}>
22+
{Icon && <Icon sx={styles.icon} />}
23+
<input
24+
style={styles.input}
25+
value={inputValue}
26+
placeholder={placeholder}
27+
onChange={(e) => {
28+
setInputValue(e.currentTarget.value)
29+
onChange(e.currentTarget.value)
30+
}}
31+
/>
32+
</Flex>
33+
)
34+
}
35+
36+
export default Input

src/components/input/styles.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { SxStyleProp } from '@vtex/brand-ui'
2+
3+
const input: SxStyleProp = {
4+
background: 'none',
5+
border: '#F4F4F4',
6+
color: '#545454',
7+
fontSize: ['14px'],
8+
width: '100%',
9+
transition: 'flex 0.3s',
10+
outline: 'none',
11+
}
12+
13+
const icon: SxStyleProp = {
14+
minWidth: '16px',
15+
minHeight: '16px',
16+
width: '16px',
17+
mr: '8px',
18+
flex: 0,
19+
maxWidth: 'fit-content',
20+
}
21+
22+
const container: SxStyleProp = {
23+
paddingLeft: '12px',
24+
alignItems: 'center',
25+
justifyContent: 'center',
26+
background: '#F4F4F4',
27+
width: '100%',
28+
height: '40px',
29+
borderRadius: '4px',
30+
transition: 'all 0.3s ease-out',
31+
cursor: 'pointer',
32+
border: '1px solid #F4F4F4',
33+
34+
':hover': {
35+
transition: 'all 0.3s ease-out',
36+
border: '1px solid #3B3B3B',
37+
},
38+
}
39+
40+
export default { container, input, icon }

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export {
99
CookieBar,
1010
ShareButton,
1111
CopyLinkButton,
12+
Input,
1213
type Item,
1314
} from './lib'
1415
export { default as LibraryContextProvider } from 'utils/context/libraryContext'

src/lib/feedback-section/styles.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ type StyleFn = (opts?: { small?: boolean }) => SxStyleProp
44

55
const container: StyleFn = ({ small } = {}) => ({
66
width: '100%',
7-
paddingBottom: '16px',
8-
borderBottom: small ? 'none' : ['none', '1px solid #E7E9EE'],
97
flexDirection: small ? 'column' : ['column', 'row'],
108
alignItems: small ? 'flex-start' : 'center',
119
alignContent: ['initial', 'space-between'],

src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export { default as CookieBar } from './cookie-bar'
99
export { default as WhatsNextCard } from '../components/whats-next-card'
1010
export { default as ShareButton } from '../components/share-button'
1111
export { default as CopyLinkButton } from '../components/copy-link-button'
12+
export { default as Input } from '../components/input'
1213
export type { Item } from './table-of-contents'

0 commit comments

Comments
 (0)