@sproutsocial/seeds-react-icon 2.3.6 → 2.4.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.
- package/dist/esm/chunk-G3D4UOOY.js +61 -0
- package/dist/esm/chunk-G3D4UOOY.js.map +1 -0
- package/dist/esm/index.js +9 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/v2/index.js +8 -0
- package/dist/esm/v2/index.js.map +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +65 -6
- package/dist/index.js.map +1 -1
- package/dist/v2/index.d.mts +37 -0
- package/dist/v2/index.d.ts +37 -0
- package/dist/v2/index.js +98 -0
- package/dist/v2/index.js.map +1 -0
- package/package.json +27 -8
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// src/v2/Icon.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
// src/v2/styles.ts
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
import { COMMON, FLEXBOX, LAYOUT } from "@sproutsocial/seeds-react-system-props";
|
|
7
|
+
var dimensions = {
|
|
8
|
+
default: { container: "24px", icon: "18px" },
|
|
9
|
+
small: { container: "20px", icon: "15px" }
|
|
10
|
+
};
|
|
11
|
+
var Container = styled.span`
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
flex-shrink: 0;
|
|
16
|
+
color: inherit;
|
|
17
|
+
width: ${(props) => dimensions[props.iconSize].container};
|
|
18
|
+
height: ${(props) => dimensions[props.iconSize].container};
|
|
19
|
+
|
|
20
|
+
& > svg {
|
|
21
|
+
width: ${(props) => dimensions[props.iconSize].icon};
|
|
22
|
+
height: ${(props) => dimensions[props.iconSize].icon};
|
|
23
|
+
flex-shrink: 0;
|
|
24
|
+
fill: currentColor;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
${COMMON}
|
|
28
|
+
${FLEXBOX}
|
|
29
|
+
${LAYOUT}
|
|
30
|
+
`;
|
|
31
|
+
var styles_default = Container;
|
|
32
|
+
|
|
33
|
+
// src/v2/Icon.tsx
|
|
34
|
+
import { jsx } from "react/jsx-runtime";
|
|
35
|
+
var Icon = React.forwardRef(
|
|
36
|
+
({ size = "default", children, icon, "aria-label": ariaLabel, ...rest }, ref) => {
|
|
37
|
+
const content = children ?? icon;
|
|
38
|
+
const ariaProps = ariaLabel ? { role: "img", "aria-label": ariaLabel } : { "aria-hidden": true };
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
40
|
+
styles_default,
|
|
41
|
+
{
|
|
42
|
+
ref,
|
|
43
|
+
iconSize: size,
|
|
44
|
+
"data-qa-icon-v2": size,
|
|
45
|
+
...ariaProps,
|
|
46
|
+
...rest,
|
|
47
|
+
children: content
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
Icon.displayName = "IconV2";
|
|
53
|
+
var Icon_default = Icon;
|
|
54
|
+
|
|
55
|
+
// src/v2/IconTypes.ts
|
|
56
|
+
import "react";
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
Icon_default
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=chunk-G3D4UOOY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/v2/Icon.tsx","../../src/v2/styles.ts","../../src/v2/IconTypes.ts"],"sourcesContent":["import * as React from \"react\";\nimport Container from \"./styles\";\nimport type { TypeIconV2Props } from \"./IconTypes\";\n\n/**\n * **Icon (v2)** — a structural wrapper that centers a caller-supplied SVG inside a\n * fixed-size container, slightly larger than the icon to give it breathing room\n * (a buffer against focus rings, hover backgrounds, and button padding).\n *\n * The caller passes the SVG directly via `children` (or the `icon` alias). The SVG\n * should use `viewBox=\"0 0 24 24\"` and `currentColor` fills — the component controls\n * only the rendered width/height and centering, never the viewBox or path-level fills.\n *\n * Sizes:\n * - `default` — 24×24px container, icon renders at 18×18px\n * - `small` — 20×20px container, icon renders at 15×15px\n *\n * Accessibility: decorative by default (`aria-hidden`). Pass `aria-label` to expose a\n * standalone icon — the container then gets `role=\"img\"` and the label.\n *\n * @example\n * <Icon aria-label=\"Settings\"><MySvg /></Icon>\n */\nconst Icon = React.forwardRef<HTMLSpanElement, TypeIconV2Props>(\n ({ size = \"default\", children, icon, \"aria-label\": ariaLabel, ...rest }, ref) => {\n const content = children ?? icon;\n const ariaProps = ariaLabel\n ? { role: \"img\" as const, \"aria-label\": ariaLabel }\n : { \"aria-hidden\": true };\n\n return (\n <Container\n ref={ref}\n iconSize={size}\n data-qa-icon-v2={size}\n {...ariaProps}\n {...rest}\n >\n {content}\n </Container>\n );\n }\n);\n\nIcon.displayName = \"IconV2\";\n\nexport default Icon;\n","import styled from \"styled-components\";\nimport { COMMON, FLEXBOX, LAYOUT } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeIconV2Size } from \"./IconTypes\";\n\nconst dimensions: { [key in TypeIconV2Size]: { container: string; icon: string } } = {\n default: { container: \"24px\", icon: \"18px\" },\n small: { container: \"20px\", icon: \"15px\" },\n};\n\n/**\n * Structural, non-semantic container that centers a caller-supplied SVG inside a\n * fixed-size box (slightly larger than the icon, for breathing room). The child\n * `svg` is sized via CSS to the icon dimensions and inherits color through\n * `currentColor` — no background or border.\n */\nconst Container = styled.span<{\n iconSize: TypeIconV2Size;\n}>`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n color: inherit;\n width: ${(props) => dimensions[props.iconSize].container};\n height: ${(props) => dimensions[props.iconSize].container};\n\n & > svg {\n width: ${(props) => dimensions[props.iconSize].icon};\n height: ${(props) => dimensions[props.iconSize].icon};\n flex-shrink: 0;\n fill: currentColor;\n }\n\n ${COMMON}\n ${FLEXBOX}\n ${LAYOUT}\n`;\n\nexport default Container;\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\n\nexport type TypeIconV2Size =\n | \"default\" // 24x24 container, 18x18 icon\n | \"small\"; // 20x20 container, 15x15 icon\n\nexport interface TypeIconV2Props\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"span\">, \"color\"> {\n /** Container/icon size variant. Defaults to `\"default\"` (24px container, 18px icon). */\n size?: TypeIconV2Size;\n /** The SVG element to render inside the container. Should use `viewBox=\"0 0 24 24\"` and `currentColor` fills. */\n children?: React.ReactNode;\n /** Alias for `children`. When both are provided, `children` wins. */\n icon?: React.ReactNode;\n /** When provided, the container gets `role=\"img\"` and this label, making a standalone icon accessible. Omit for decorative icons (the container is `aria-hidden` automatically). */\n \"aria-label\"?: string;\n}\n"],"mappings":";AAAA,YAAY,WAAW;;;ACAvB,OAAO,YAAY;AACnB,SAAS,QAAQ,SAAS,cAAc;AAGxC,IAAM,aAA+E;AAAA,EACnF,SAAS,EAAE,WAAW,QAAQ,MAAM,OAAO;AAAA,EAC3C,OAAO,EAAE,WAAW,QAAQ,MAAM,OAAO;AAC3C;AAQA,IAAM,YAAY,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAQd,CAAC,UAAU,WAAW,MAAM,QAAQ,EAAE,SAAS;AAAA,YAC9C,CAAC,UAAU,WAAW,MAAM,QAAQ,EAAE,SAAS;AAAA;AAAA;AAAA,aAG9C,CAAC,UAAU,WAAW,MAAM,QAAQ,EAAE,IAAI;AAAA,cACzC,CAAC,UAAU,WAAW,MAAM,QAAQ,EAAE,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,IAKpD,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA;AAGV,IAAO,iBAAQ;;;ADPT;AARN,IAAM,OAAa;AAAA,EACjB,CAAC,EAAE,OAAO,WAAW,UAAU,MAAM,cAAc,WAAW,GAAG,KAAK,GAAG,QAAQ;AAC/E,UAAM,UAAU,YAAY;AAC5B,UAAM,YAAY,YACd,EAAE,MAAM,OAAgB,cAAc,UAAU,IAChD,EAAE,eAAe,KAAK;AAE1B,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,UAAU;AAAA,QACV,mBAAiB;AAAA,QAChB,GAAG;AAAA,QACH,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,KAAK,cAAc;AAEnB,IAAO,eAAQ;;;AE9Cf,OAAuB;","names":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Icon_default
|
|
3
|
+
} from "./chunk-G3D4UOOY.js";
|
|
4
|
+
|
|
1
5
|
// src/Icon.tsx
|
|
2
6
|
import "react";
|
|
3
7
|
import styled2, { css as css2 } from "styled-components";
|
|
@@ -187,16 +191,17 @@ var IconToggle = ({
|
|
|
187
191
|
};
|
|
188
192
|
IconToggle.displayName = "Icon.Toggle";
|
|
189
193
|
Icon.Toggle = IconToggle;
|
|
190
|
-
var
|
|
194
|
+
var Icon_default2 = Icon;
|
|
191
195
|
|
|
192
196
|
// src/IconTypes.ts
|
|
193
197
|
import "react";
|
|
194
198
|
|
|
195
199
|
// src/index.ts
|
|
196
|
-
var
|
|
200
|
+
var src_default = Icon_default2;
|
|
197
201
|
export {
|
|
198
|
-
|
|
202
|
+
Icon_default2 as Icon,
|
|
199
203
|
styles_default as IconContainer,
|
|
200
|
-
|
|
204
|
+
Icon_default as IconV2,
|
|
205
|
+
src_default as default
|
|
201
206
|
};
|
|
202
207
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Icon.tsx","../../src/styles.ts","../../src/IconTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport styled, { css } from \"styled-components\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport PartnerLogo from \"@sproutsocial/seeds-react-partner-logo\";\nimport { includes } from \"@sproutsocial/seeds-react-utilities\";\nimport { LogoNamesWithoutVariants as PartnerLogoNames } from \"@sproutsocial/seeds-partner-logos\";\n\nimport type { TypeIconProps, TypeToggleProps } from \"./IconTypes\";\nimport Container from \"./styles\";\nimport {\n AiViewBoxes,\n ExternalViewBoxes,\n GeneralViewBoxes,\n SproutViewBoxes,\n ExternalIconNames,\n type EnumIconSvgNames,\n type EnumIconNamesWithoutVariants,\n} from \"@sproutsocial/seeds-icons\";\n\nconst AllViewboxes = {\n ...AiViewBoxes,\n ...ExternalViewBoxes,\n ...GeneralViewBoxes,\n ...SproutViewBoxes,\n};\n\nconst Icon = ({\n name,\n size = \"small\",\n fixedWidth = false,\n ariaLabel,\n color,\n svgProps,\n ...rest\n}: TypeIconProps) => {\n if (includes(PartnerLogoNames, name)) {\n // Icon's \"default\" size is equivalent to PartnerLogo's \"small\" size\n const logoSize = size === \"default\" ? \"small\" : size;\n const logoProps = {\n partnerName: name,\n size: logoSize,\n logoType: \"symbol\" as const,\n svgProps,\n };\n return (\n <PartnerLogo\n // ariaLabel needs to be overridable by aria-label prop in ...rest\n aria-label={ariaLabel}\n {...rest}\n {...logoProps}\n />\n );\n }\n\n const defaultVariant = size === \"mini\" ? \"solid\" : \"outline\";\n\n const iconName: EnumIconSvgNames =\n // if not external and has no variant\n !name?.endsWith(\"-outline\") &&\n !name?.endsWith(\"-solid\") &&\n !includes(ExternalIconNames, name)\n ? // then add default variant\n `${name as EnumIconNamesWithoutVariants}-${defaultVariant}`\n : // else use name as is\n (name as EnumIconSvgNames);\n\n const iconViewBox = AllViewboxes[iconName];\n\n const { \"aria-label\": ariaLabelFromRest, ...restWithoutAriaLabel } = rest;\n const hasAriaLabel = !!ariaLabel || !!ariaLabelFromRest;\n const containerAriaProps = hasAriaLabel ? {} : { \"aria-hidden\": \"true\" };\n const svgAriaProps = hasAriaLabel\n ? { role: \"img\", \"aria-label\": ariaLabel ?? ariaLabelFromRest }\n : {};\n\n return (\n <Container\n iconSize={size}\n fixedWidth={!!fixedWidth}\n key={iconName}\n data-qa-icon={iconName}\n color={color}\n {...restWithoutAriaLabel}\n {...containerAriaProps}\n >\n <svg\n className=\"Icon-svg\"\n viewBox={iconViewBox}\n focusable={false}\n data-qa-icon-svg={`${iconName}-svg`}\n {...svgProps}\n {...svgAriaProps}\n >\n <use\n xmlnsXlink=\"http://www.w3.org/1999/xlink\"\n xlinkHref={`#seeds-svgs_${iconName}`}\n />\n </svg>\n </Container>\n );\n};\n\nconst ToggleableIcon = styled(Icon)<{ active: boolean }>`\n transition: all ${(p) => p.theme.duration.fast} linear;\n\n ${(p) =>\n p.active &&\n css`\n opacity: 1;\n transform: scale(1);\n `}\n\n ${(p) =>\n !p.active &&\n css`\n position: absolute;\n opacity: 0;\n transform: scale(0);\n `}\n`;\n\nconst IconToggle = ({\n activeName,\n inactiveName,\n isActive,\n size = \"small\",\n fixedWidth = false,\n ariaLabel,\n ...rest\n}: TypeToggleProps) => {\n return (\n <Box as=\"span\" position=\"relative\" display=\"inline-flex\" {...rest}>\n <ToggleableIcon\n active={isActive}\n name={activeName}\n size={size}\n fixedWidth={fixedWidth}\n aria-hidden={!isActive}\n aria-label={!isActive ? undefined : ariaLabel}\n />\n <ToggleableIcon\n active={!isActive}\n name={inactiveName}\n size={size}\n fixedWidth={fixedWidth}\n aria-hidden={isActive}\n aria-label={isActive ? ariaLabel : undefined}\n />\n </Box>\n );\n};\n\nIconToggle.displayName = \"Icon.Toggle\";\n/**\n * **Accessibility note:** It is best practice to wrap `<Icon.Toggle />` in a button. The button must include `aria-label` and `aria-pressed` in order for a screen reader to properly communicate the icon's state. See example below.\n *\n * @link https://www.w3.org/TR/wai-aria-practices-1.1/#button\n * @example\n * const [toggleState, setToggleState] = useState(false);\n * <Button // Wrap Icon.Toggle with Button\n * appearance='pill'\n * aria-label='like' // required for accessibility\n * aria-pressed={toggleState} // required for accessibility\n * onClick={() => setToggleState(!toggleState)}\n * >\n * <Icon.Toggle\n * activeName=\"heart-solid\"\n * inactiveName=\"heart-outline\"\n * isActive={toggleState}\n * />\n * </Button>\n */\nIcon.Toggle = IconToggle;\n\nexport default Icon;\n","import styled, { css } from \"styled-components\";\nimport { verticalAlign } from \"styled-system\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeIconSize } from \"./IconTypes\";\n\nconst sizes: { [key in TypeIconSize]: string } = {\n mini: \"12px\",\n\n /** TODO: deprecate default in favor of small in future release */\n default: \"16px\",\n small: \"16px\",\n medium: \"24px\",\n large: \"32px\",\n jumbo: \"64px\",\n};\n\nconst stylesForSize = (iconActualSize: string, fixedWidth: boolean) => css`\n line-height: ${iconActualSize};\n\n &,\n .Icon-svg {\n height: ${iconActualSize};\n fill: currentColor;\n }\n\n ${fixedWidth &&\n `\n &,\n & .Icon-svg {\n width: ${iconActualSize}\n }\n `}\n`;\n\nconst Container = styled.span.attrs({\n className: \"Icon\",\n})<{\n iconSize: TypeIconSize;\n fixedWidth: boolean;\n}>`\n display: inline-block;\n color: inherit;\n vertical-align: middle;\n\n ${(props) => stylesForSize(sizes[props.iconSize], props.fixedWidth)}\n\n ${COMMON}\n ${verticalAlign}\n`;\nexport default Container;\n","import * as React from \"react\";\nimport type { EnumIconNames } from \"@sproutsocial/seeds-icons\";\nimport type { EnumLogoNamesWithoutVariants } from \"@sproutsocial/seeds-partner-logos\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeBoxProps } from \"@sproutsocial/seeds-react-box\";\n\nexport type TypeIconName = EnumIconNames | EnumLogoNamesWithoutVariants;\n\nexport type TypeIconSize =\n | \"mini\" // 12x12\n // TODO: deprecate default in favor of small in future release\n | \"default\" // 16x16\n | \"small\" // 16x16\n | \"medium\" // 24x24\n | \"large\" // 32x32\n | \"jumbo\"; // 64x64\n\nexport interface TypeIconProps\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"span\">, \"color\"> {\n /** Name of the icon in the svg sprite */\n name: TypeIconName;\n size?: TypeIconSize;\n /** Whether the icon should have a fixed width or not. Use this when you need to align icons/text vertically in a list. */\n fixedWidth?: boolean;\n /** Label used to describe the icon if not used with an accompanying visual label */\n ariaLabel?: string;\n svgProps?: React.ComponentPropsWithoutRef<\"svg\">;\n}\n\nexport interface TypeToggleProps extends TypeBoxProps {\n /** Name of the icon to be shown in the active state */\n activeName: TypeIconName;\n /** Name of the icon to be shown in the inactive state */\n inactiveName: TypeIconName;\n /** Whether the active icon should be shown or not */\n isActive: boolean;\n /** The size of the icon. `small` is the default */\n size?: TypeIconSize;\n fixedWidth?: boolean;\n ariaLabel?: string;\n}\n","import Icon from \"./Icon\";\n\nexport default Icon;\nexport { Icon };\nexport { default as IconContainer } from \"./styles\";\nexport * from \"./IconTypes\";\n"],"mappings":";AAAA,OAAuB;AACvB,OAAOA,WAAU,OAAAC,YAAW;AAC5B,OAAO,SAAS;AAChB,OAAO,iBAAiB;AACxB,SAAS,gBAAgB;AACzB,SAAS,4BAA4B,wBAAwB;;;ACL7D,OAAO,UAAU,WAAW;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AAGvB,IAAM,QAA2C;AAAA,EAC/C,MAAM;AAAA;AAAA,EAGN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEA,IAAM,gBAAgB,CAAC,gBAAwB,eAAwB;AAAA,iBACtD,cAAc;AAAA;AAAA;AAAA;AAAA,cAIjB,cAAc;AAAA;AAAA;AAAA;AAAA,IAIxB,cACF;AAAA;AAAA;AAAA,eAGa,cAAc;AAAA;AAAA,GAE1B;AAAA;AAGH,IAAM,YAAY,OAAO,KAAK,MAAM;AAAA,EAClC,WAAW;AACb,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,IAQG,CAAC,UAAU,cAAc,MAAM,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC;A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,IAAO,gBAAQ;","names":["styled","css","styled","css"]}
|
|
1
|
+
{"version":3,"sources":["../../src/Icon.tsx","../../src/styles.ts","../../src/IconTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport styled, { css } from \"styled-components\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport PartnerLogo from \"@sproutsocial/seeds-react-partner-logo\";\nimport { includes } from \"@sproutsocial/seeds-react-utilities\";\nimport { LogoNamesWithoutVariants as PartnerLogoNames } from \"@sproutsocial/seeds-partner-logos\";\n\nimport type { TypeIconProps, TypeToggleProps } from \"./IconTypes\";\nimport Container from \"./styles\";\nimport {\n AiViewBoxes,\n ExternalViewBoxes,\n GeneralViewBoxes,\n SproutViewBoxes,\n ExternalIconNames,\n type EnumIconSvgNames,\n type EnumIconNamesWithoutVariants,\n} from \"@sproutsocial/seeds-icons\";\n\nconst AllViewboxes = {\n ...AiViewBoxes,\n ...ExternalViewBoxes,\n ...GeneralViewBoxes,\n ...SproutViewBoxes,\n};\n\nconst Icon = ({\n name,\n size = \"small\",\n fixedWidth = false,\n ariaLabel,\n color,\n svgProps,\n ...rest\n}: TypeIconProps) => {\n if (includes(PartnerLogoNames, name)) {\n // Icon's \"default\" size is equivalent to PartnerLogo's \"small\" size\n const logoSize = size === \"default\" ? \"small\" : size;\n const logoProps = {\n partnerName: name,\n size: logoSize,\n logoType: \"symbol\" as const,\n svgProps,\n };\n return (\n <PartnerLogo\n // ariaLabel needs to be overridable by aria-label prop in ...rest\n aria-label={ariaLabel}\n {...rest}\n {...logoProps}\n />\n );\n }\n\n const defaultVariant = size === \"mini\" ? \"solid\" : \"outline\";\n\n const iconName: EnumIconSvgNames =\n // if not external and has no variant\n !name?.endsWith(\"-outline\") &&\n !name?.endsWith(\"-solid\") &&\n !includes(ExternalIconNames, name)\n ? // then add default variant\n `${name as EnumIconNamesWithoutVariants}-${defaultVariant}`\n : // else use name as is\n (name as EnumIconSvgNames);\n\n const iconViewBox = AllViewboxes[iconName];\n\n const { \"aria-label\": ariaLabelFromRest, ...restWithoutAriaLabel } = rest;\n const hasAriaLabel = !!ariaLabel || !!ariaLabelFromRest;\n const containerAriaProps = hasAriaLabel ? {} : { \"aria-hidden\": \"true\" };\n const svgAriaProps = hasAriaLabel\n ? { role: \"img\", \"aria-label\": ariaLabel ?? ariaLabelFromRest }\n : {};\n\n return (\n <Container\n iconSize={size}\n fixedWidth={!!fixedWidth}\n key={iconName}\n data-qa-icon={iconName}\n color={color}\n {...restWithoutAriaLabel}\n {...containerAriaProps}\n >\n <svg\n className=\"Icon-svg\"\n viewBox={iconViewBox}\n focusable={false}\n data-qa-icon-svg={`${iconName}-svg`}\n {...svgProps}\n {...svgAriaProps}\n >\n <use\n xmlnsXlink=\"http://www.w3.org/1999/xlink\"\n xlinkHref={`#seeds-svgs_${iconName}`}\n />\n </svg>\n </Container>\n );\n};\n\nconst ToggleableIcon = styled(Icon)<{ active: boolean }>`\n transition: all ${(p) => p.theme.duration.fast} linear;\n\n ${(p) =>\n p.active &&\n css`\n opacity: 1;\n transform: scale(1);\n `}\n\n ${(p) =>\n !p.active &&\n css`\n position: absolute;\n opacity: 0;\n transform: scale(0);\n `}\n`;\n\nconst IconToggle = ({\n activeName,\n inactiveName,\n isActive,\n size = \"small\",\n fixedWidth = false,\n ariaLabel,\n ...rest\n}: TypeToggleProps) => {\n return (\n <Box as=\"span\" position=\"relative\" display=\"inline-flex\" {...rest}>\n <ToggleableIcon\n active={isActive}\n name={activeName}\n size={size}\n fixedWidth={fixedWidth}\n aria-hidden={!isActive}\n aria-label={!isActive ? undefined : ariaLabel}\n />\n <ToggleableIcon\n active={!isActive}\n name={inactiveName}\n size={size}\n fixedWidth={fixedWidth}\n aria-hidden={isActive}\n aria-label={isActive ? ariaLabel : undefined}\n />\n </Box>\n );\n};\n\nIconToggle.displayName = \"Icon.Toggle\";\n/**\n * **Accessibility note:** It is best practice to wrap `<Icon.Toggle />` in a button. The button must include `aria-label` and `aria-pressed` in order for a screen reader to properly communicate the icon's state. See example below.\n *\n * @link https://www.w3.org/TR/wai-aria-practices-1.1/#button\n * @example\n * const [toggleState, setToggleState] = useState(false);\n * <Button // Wrap Icon.Toggle with Button\n * appearance='pill'\n * aria-label='like' // required for accessibility\n * aria-pressed={toggleState} // required for accessibility\n * onClick={() => setToggleState(!toggleState)}\n * >\n * <Icon.Toggle\n * activeName=\"heart-solid\"\n * inactiveName=\"heart-outline\"\n * isActive={toggleState}\n * />\n * </Button>\n */\nIcon.Toggle = IconToggle;\n\nexport default Icon;\n","import styled, { css } from \"styled-components\";\nimport { verticalAlign } from \"styled-system\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeIconSize } from \"./IconTypes\";\n\nconst sizes: { [key in TypeIconSize]: string } = {\n mini: \"12px\",\n\n /** TODO: deprecate default in favor of small in future release */\n default: \"16px\",\n small: \"16px\",\n medium: \"24px\",\n large: \"32px\",\n jumbo: \"64px\",\n};\n\nconst stylesForSize = (iconActualSize: string, fixedWidth: boolean) => css`\n line-height: ${iconActualSize};\n\n &,\n .Icon-svg {\n height: ${iconActualSize};\n fill: currentColor;\n }\n\n ${fixedWidth &&\n `\n &,\n & .Icon-svg {\n width: ${iconActualSize}\n }\n `}\n`;\n\nconst Container = styled.span.attrs({\n className: \"Icon\",\n})<{\n iconSize: TypeIconSize;\n fixedWidth: boolean;\n}>`\n display: inline-block;\n color: inherit;\n vertical-align: middle;\n\n ${(props) => stylesForSize(sizes[props.iconSize], props.fixedWidth)}\n\n ${COMMON}\n ${verticalAlign}\n`;\nexport default Container;\n","import * as React from \"react\";\nimport type { EnumIconNames } from \"@sproutsocial/seeds-icons\";\nimport type { EnumLogoNamesWithoutVariants } from \"@sproutsocial/seeds-partner-logos\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeBoxProps } from \"@sproutsocial/seeds-react-box\";\n\nexport type TypeIconName = EnumIconNames | EnumLogoNamesWithoutVariants;\n\nexport type TypeIconSize =\n | \"mini\" // 12x12\n // TODO: deprecate default in favor of small in future release\n | \"default\" // 16x16\n | \"small\" // 16x16\n | \"medium\" // 24x24\n | \"large\" // 32x32\n | \"jumbo\"; // 64x64\n\nexport interface TypeIconProps\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"span\">, \"color\"> {\n /** Name of the icon in the svg sprite */\n name: TypeIconName;\n size?: TypeIconSize;\n /** Whether the icon should have a fixed width or not. Use this when you need to align icons/text vertically in a list. */\n fixedWidth?: boolean;\n /** Label used to describe the icon if not used with an accompanying visual label */\n ariaLabel?: string;\n svgProps?: React.ComponentPropsWithoutRef<\"svg\">;\n}\n\nexport interface TypeToggleProps extends TypeBoxProps {\n /** Name of the icon to be shown in the active state */\n activeName: TypeIconName;\n /** Name of the icon to be shown in the inactive state */\n inactiveName: TypeIconName;\n /** Whether the active icon should be shown or not */\n isActive: boolean;\n /** The size of the icon. `small` is the default */\n size?: TypeIconSize;\n fixedWidth?: boolean;\n ariaLabel?: string;\n}\n","import Icon from \"./Icon\";\n\nexport default Icon;\nexport { Icon };\nexport { default as IconContainer } from \"./styles\";\nexport * from \"./IconTypes\";\n\n// Icon v2 exports (structural SVG wrapper; distinct API from v1)\nexport { default as IconV2 } from \"./v2\";\nexport type { TypeIconV2Props, TypeIconV2Size } from \"./v2\";\n"],"mappings":";;;;;AAAA,OAAuB;AACvB,OAAOA,WAAU,OAAAC,YAAW;AAC5B,OAAO,SAAS;AAChB,OAAO,iBAAiB;AACxB,SAAS,gBAAgB;AACzB,SAAS,4BAA4B,wBAAwB;;;ACL7D,OAAO,UAAU,WAAW;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AAGvB,IAAM,QAA2C;AAAA,EAC/C,MAAM;AAAA;AAAA,EAGN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AA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A,QACN;AAAA,QACA;AAAA,QACA,eAAa,CAAC;AAAA,QACd,cAAY,CAAC,WAAW,SAAY;AAAA;AAAA,IACtC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ,CAAC;AAAA,QACT,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA,eAAa;AAAA,QACb,cAAY,WAAW,YAAY;AAAA;AAAA,IACrC;AAAA,KACF;AAEJ;AAEA,WAAW,cAAc;AAoBzB,KAAK,SAAS;AAEd,IAAOC,gBAAQ;;;AE9Kf,OAAuB;;;ACEvB,IAAO,cAAQC;","names":["styled","css","styled","css","Icon_default","Icon_default"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,7 @@ import { EnumLogoNamesWithoutVariants } from '@sproutsocial/seeds-partner-logos'
|
|
|
5
5
|
import { TypeStyledComponentsCommonProps, TypeSystemCommonProps } from '@sproutsocial/seeds-react-system-props';
|
|
6
6
|
import { TypeBoxProps } from '@sproutsocial/seeds-react-box';
|
|
7
7
|
import * as styled_components from 'styled-components';
|
|
8
|
+
export { Icon as IconV2, TypeIconV2Props, TypeIconV2Size } from './v2/index.mjs';
|
|
8
9
|
|
|
9
10
|
type TypeIconName = EnumIconNames | EnumLogoNamesWithoutVariants;
|
|
10
11
|
type TypeIconSize = "mini" | "default" | "small" | "medium" | "large" | "jumbo";
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { EnumLogoNamesWithoutVariants } from '@sproutsocial/seeds-partner-logos'
|
|
|
5
5
|
import { TypeStyledComponentsCommonProps, TypeSystemCommonProps } from '@sproutsocial/seeds-react-system-props';
|
|
6
6
|
import { TypeBoxProps } from '@sproutsocial/seeds-react-box';
|
|
7
7
|
import * as styled_components from 'styled-components';
|
|
8
|
+
export { Icon as IconV2, TypeIconV2Props, TypeIconV2Size } from './v2/index.js';
|
|
8
9
|
|
|
9
10
|
type TypeIconName = EnumIconNames | EnumLogoNamesWithoutVariants;
|
|
10
11
|
type TypeIconSize = "mini" | "default" | "small" | "medium" | "large" | "jumbo";
|
package/dist/index.js
CHANGED
|
@@ -28,13 +28,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
33
|
Icon: () => Icon_default,
|
|
34
34
|
IconContainer: () => styles_default,
|
|
35
|
-
|
|
35
|
+
IconV2: () => Icon_default2,
|
|
36
|
+
default: () => src_default
|
|
36
37
|
});
|
|
37
|
-
module.exports = __toCommonJS(
|
|
38
|
+
module.exports = __toCommonJS(src_exports);
|
|
38
39
|
|
|
39
40
|
// src/Icon.tsx
|
|
40
41
|
var React = require("react");
|
|
@@ -224,11 +225,69 @@ var Icon_default = Icon;
|
|
|
224
225
|
// src/IconTypes.ts
|
|
225
226
|
var React2 = require("react");
|
|
226
227
|
|
|
228
|
+
// src/v2/Icon.tsx
|
|
229
|
+
var React3 = __toESM(require("react"));
|
|
230
|
+
|
|
231
|
+
// src/v2/styles.ts
|
|
232
|
+
var import_styled_components3 = __toESM(require("styled-components"));
|
|
233
|
+
var import_seeds_react_system_props2 = require("@sproutsocial/seeds-react-system-props");
|
|
234
|
+
var dimensions = {
|
|
235
|
+
default: { container: "24px", icon: "18px" },
|
|
236
|
+
small: { container: "20px", icon: "15px" }
|
|
237
|
+
};
|
|
238
|
+
var Container2 = import_styled_components3.default.span`
|
|
239
|
+
display: inline-flex;
|
|
240
|
+
align-items: center;
|
|
241
|
+
justify-content: center;
|
|
242
|
+
flex-shrink: 0;
|
|
243
|
+
color: inherit;
|
|
244
|
+
width: ${(props) => dimensions[props.iconSize].container};
|
|
245
|
+
height: ${(props) => dimensions[props.iconSize].container};
|
|
246
|
+
|
|
247
|
+
& > svg {
|
|
248
|
+
width: ${(props) => dimensions[props.iconSize].icon};
|
|
249
|
+
height: ${(props) => dimensions[props.iconSize].icon};
|
|
250
|
+
flex-shrink: 0;
|
|
251
|
+
fill: currentColor;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
${import_seeds_react_system_props2.COMMON}
|
|
255
|
+
${import_seeds_react_system_props2.FLEXBOX}
|
|
256
|
+
${import_seeds_react_system_props2.LAYOUT}
|
|
257
|
+
`;
|
|
258
|
+
var styles_default2 = Container2;
|
|
259
|
+
|
|
260
|
+
// src/v2/Icon.tsx
|
|
261
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
262
|
+
var Icon2 = React3.forwardRef(
|
|
263
|
+
({ size = "default", children, icon, "aria-label": ariaLabel, ...rest }, ref) => {
|
|
264
|
+
const content = children ?? icon;
|
|
265
|
+
const ariaProps = ariaLabel ? { role: "img", "aria-label": ariaLabel } : { "aria-hidden": true };
|
|
266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
267
|
+
styles_default2,
|
|
268
|
+
{
|
|
269
|
+
ref,
|
|
270
|
+
iconSize: size,
|
|
271
|
+
"data-qa-icon-v2": size,
|
|
272
|
+
...ariaProps,
|
|
273
|
+
...rest,
|
|
274
|
+
children: content
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
Icon2.displayName = "IconV2";
|
|
280
|
+
var Icon_default2 = Icon2;
|
|
281
|
+
|
|
282
|
+
// src/v2/IconTypes.ts
|
|
283
|
+
var React4 = require("react");
|
|
284
|
+
|
|
227
285
|
// src/index.ts
|
|
228
|
-
var
|
|
286
|
+
var src_default = Icon_default;
|
|
229
287
|
// Annotate the CommonJS export names for ESM import in node:
|
|
230
288
|
0 && (module.exports = {
|
|
231
289
|
Icon,
|
|
232
|
-
IconContainer
|
|
290
|
+
IconContainer,
|
|
291
|
+
IconV2
|
|
233
292
|
});
|
|
234
293
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/Icon.tsx","../src/styles.ts","../src/IconTypes.ts"],"sourcesContent":["import Icon from \"./Icon\";\n\nexport default Icon;\nexport { Icon };\nexport { default as IconContainer } from \"./styles\";\nexport * from \"./IconTypes\";\n","import * as React from \"react\";\nimport styled, { css } from \"styled-components\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport PartnerLogo from \"@sproutsocial/seeds-react-partner-logo\";\nimport { includes } from \"@sproutsocial/seeds-react-utilities\";\nimport { LogoNamesWithoutVariants as PartnerLogoNames } from \"@sproutsocial/seeds-partner-logos\";\n\nimport type { TypeIconProps, TypeToggleProps } from \"./IconTypes\";\nimport Container from \"./styles\";\nimport {\n AiViewBoxes,\n ExternalViewBoxes,\n GeneralViewBoxes,\n SproutViewBoxes,\n ExternalIconNames,\n type EnumIconSvgNames,\n type EnumIconNamesWithoutVariants,\n} from \"@sproutsocial/seeds-icons\";\n\nconst AllViewboxes = {\n ...AiViewBoxes,\n ...ExternalViewBoxes,\n ...GeneralViewBoxes,\n ...SproutViewBoxes,\n};\n\nconst Icon = ({\n name,\n size = \"small\",\n fixedWidth = false,\n ariaLabel,\n color,\n svgProps,\n ...rest\n}: TypeIconProps) => {\n if (includes(PartnerLogoNames, name)) {\n // Icon's \"default\" size is equivalent to PartnerLogo's \"small\" size\n const logoSize = size === \"default\" ? \"small\" : size;\n const logoProps = {\n partnerName: name,\n size: logoSize,\n logoType: \"symbol\" as const,\n svgProps,\n };\n return (\n <PartnerLogo\n // ariaLabel needs to be overridable by aria-label prop in ...rest\n aria-label={ariaLabel}\n {...rest}\n {...logoProps}\n />\n );\n }\n\n const defaultVariant = size === \"mini\" ? \"solid\" : \"outline\";\n\n const iconName: EnumIconSvgNames =\n // if not external and has no variant\n !name?.endsWith(\"-outline\") &&\n !name?.endsWith(\"-solid\") &&\n !includes(ExternalIconNames, name)\n ? // then add default variant\n `${name as EnumIconNamesWithoutVariants}-${defaultVariant}`\n : // else use name as is\n (name as EnumIconSvgNames);\n\n const iconViewBox = AllViewboxes[iconName];\n\n const { \"aria-label\": ariaLabelFromRest, ...restWithoutAriaLabel } = rest;\n const hasAriaLabel = !!ariaLabel || !!ariaLabelFromRest;\n const containerAriaProps = hasAriaLabel ? {} : { \"aria-hidden\": \"true\" };\n const svgAriaProps = hasAriaLabel\n ? { role: \"img\", \"aria-label\": ariaLabel ?? ariaLabelFromRest }\n : {};\n\n return (\n <Container\n iconSize={size}\n fixedWidth={!!fixedWidth}\n key={iconName}\n data-qa-icon={iconName}\n color={color}\n {...restWithoutAriaLabel}\n {...containerAriaProps}\n >\n <svg\n className=\"Icon-svg\"\n viewBox={iconViewBox}\n focusable={false}\n data-qa-icon-svg={`${iconName}-svg`}\n {...svgProps}\n {...svgAriaProps}\n >\n <use\n xmlnsXlink=\"http://www.w3.org/1999/xlink\"\n xlinkHref={`#seeds-svgs_${iconName}`}\n />\n </svg>\n </Container>\n );\n};\n\nconst ToggleableIcon = styled(Icon)<{ active: boolean }>`\n transition: all ${(p) => p.theme.duration.fast} linear;\n\n ${(p) =>\n p.active &&\n css`\n opacity: 1;\n transform: scale(1);\n `}\n\n ${(p) =>\n !p.active &&\n css`\n position: absolute;\n opacity: 0;\n transform: scale(0);\n `}\n`;\n\nconst IconToggle = ({\n activeName,\n inactiveName,\n isActive,\n size = \"small\",\n fixedWidth = false,\n ariaLabel,\n ...rest\n}: TypeToggleProps) => {\n return (\n <Box as=\"span\" position=\"relative\" display=\"inline-flex\" {...rest}>\n <ToggleableIcon\n active={isActive}\n name={activeName}\n size={size}\n fixedWidth={fixedWidth}\n aria-hidden={!isActive}\n aria-label={!isActive ? undefined : ariaLabel}\n />\n <ToggleableIcon\n active={!isActive}\n name={inactiveName}\n size={size}\n fixedWidth={fixedWidth}\n aria-hidden={isActive}\n aria-label={isActive ? ariaLabel : undefined}\n />\n </Box>\n );\n};\n\nIconToggle.displayName = \"Icon.Toggle\";\n/**\n * **Accessibility note:** It is best practice to wrap `<Icon.Toggle />` in a button. The button must include `aria-label` and `aria-pressed` in order for a screen reader to properly communicate the icon's state. See example below.\n *\n * @link https://www.w3.org/TR/wai-aria-practices-1.1/#button\n * @example\n * const [toggleState, setToggleState] = useState(false);\n * <Button // Wrap Icon.Toggle with Button\n * appearance='pill'\n * aria-label='like' // required for accessibility\n * aria-pressed={toggleState} // required for accessibility\n * onClick={() => setToggleState(!toggleState)}\n * >\n * <Icon.Toggle\n * activeName=\"heart-solid\"\n * inactiveName=\"heart-outline\"\n * isActive={toggleState}\n * />\n * </Button>\n */\nIcon.Toggle = IconToggle;\n\nexport default Icon;\n","import styled, { css } from \"styled-components\";\nimport { verticalAlign } from \"styled-system\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeIconSize } from \"./IconTypes\";\n\nconst sizes: { [key in TypeIconSize]: string } = {\n mini: \"12px\",\n\n /** TODO: deprecate default in favor of small in future release */\n default: \"16px\",\n small: \"16px\",\n medium: \"24px\",\n large: \"32px\",\n jumbo: \"64px\",\n};\n\nconst stylesForSize = (iconActualSize: string, fixedWidth: boolean) => css`\n line-height: ${iconActualSize};\n\n &,\n .Icon-svg {\n height: ${iconActualSize};\n fill: currentColor;\n }\n\n ${fixedWidth &&\n `\n &,\n & .Icon-svg {\n width: ${iconActualSize}\n }\n `}\n`;\n\nconst Container = styled.span.attrs({\n className: \"Icon\",\n})<{\n iconSize: TypeIconSize;\n fixedWidth: boolean;\n}>`\n display: inline-block;\n color: inherit;\n vertical-align: middle;\n\n ${(props) => stylesForSize(sizes[props.iconSize], props.fixedWidth)}\n\n ${COMMON}\n ${verticalAlign}\n`;\nexport default Container;\n","import * as React from \"react\";\nimport type { EnumIconNames } from \"@sproutsocial/seeds-icons\";\nimport type { EnumLogoNamesWithoutVariants } from \"@sproutsocial/seeds-partner-logos\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeBoxProps } from \"@sproutsocial/seeds-react-box\";\n\nexport type TypeIconName = EnumIconNames | EnumLogoNamesWithoutVariants;\n\nexport type TypeIconSize =\n | \"mini\" // 12x12\n // TODO: deprecate default in favor of small in future release\n | \"default\" // 16x16\n | \"small\" // 16x16\n | \"medium\" // 24x24\n | \"large\" // 32x32\n | \"jumbo\"; // 64x64\n\nexport interface TypeIconProps\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"span\">, \"color\"> {\n /** Name of the icon in the svg sprite */\n name: TypeIconName;\n size?: TypeIconSize;\n /** Whether the icon should have a fixed width or not. Use this when you need to align icons/text vertically in a list. */\n fixedWidth?: boolean;\n /** Label used to describe the icon if not used with an accompanying visual label */\n ariaLabel?: string;\n svgProps?: React.ComponentPropsWithoutRef<\"svg\">;\n}\n\nexport interface TypeToggleProps extends TypeBoxProps {\n /** Name of the icon to be shown in the active state */\n activeName: TypeIconName;\n /** Name of the icon to be shown in the inactive state */\n inactiveName: TypeIconName;\n /** Whether the active icon should be shown or not */\n isActive: boolean;\n /** The size of the icon. `small` is the default */\n size?: TypeIconSize;\n fixedWidth?: boolean;\n ariaLabel?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,IAAAA,4BAA4B;AAC5B,6BAAgB;AAChB,sCAAwB;AACxB,mCAAyB;AACzB,iCAA6D;;;ACL7D,+BAA4B;AAC5B,2BAA8B;AAC9B,sCAAuB;AAGvB,IAAM,QAA2C;AAAA,EAC/C,MAAM;AAAA;AAAA,EAGN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEA,IAAM,gBAAgB,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AAC;AAAA,QACd,cAAY,CAAC,WAAW,SAAY;AAAA;AAAA,IACtC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ,CAAC;AAAA,QACT,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA,eAAa;AAAA,QACb,cAAY,WAAW,YAAY;AAAA;AAAA,IACrC;AAAA,KACF;AAEJ;AAEA,WAAW,cAAc;AAoBzB,KAAK,SAAS;AAEd,IAAO,eAAQ;;;AE9Kf,IAAAC,SAAuB;;;AHEvB,IAAO,gBAAQ;","names":["import_styled_components","styled","PartnerLogoNames","PartnerLogo","styled","Box","React"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/Icon.tsx","../src/styles.ts","../src/IconTypes.ts","../src/v2/Icon.tsx","../src/v2/styles.ts","../src/v2/IconTypes.ts"],"sourcesContent":["import Icon from \"./Icon\";\n\nexport default Icon;\nexport { Icon };\nexport { default as IconContainer } from \"./styles\";\nexport * from \"./IconTypes\";\n\n// Icon v2 exports (structural SVG wrapper; distinct API from v1)\nexport { default as IconV2 } from \"./v2\";\nexport type { TypeIconV2Props, TypeIconV2Size } from \"./v2\";\n","import * as React from \"react\";\nimport styled, { css } from \"styled-components\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport PartnerLogo from \"@sproutsocial/seeds-react-partner-logo\";\nimport { includes } from \"@sproutsocial/seeds-react-utilities\";\nimport { LogoNamesWithoutVariants as PartnerLogoNames } from \"@sproutsocial/seeds-partner-logos\";\n\nimport type { TypeIconProps, TypeToggleProps } from \"./IconTypes\";\nimport Container from \"./styles\";\nimport {\n AiViewBoxes,\n ExternalViewBoxes,\n GeneralViewBoxes,\n SproutViewBoxes,\n ExternalIconNames,\n type EnumIconSvgNames,\n type EnumIconNamesWithoutVariants,\n} from \"@sproutsocial/seeds-icons\";\n\nconst AllViewboxes = {\n ...AiViewBoxes,\n ...ExternalViewBoxes,\n ...GeneralViewBoxes,\n ...SproutViewBoxes,\n};\n\nconst Icon = ({\n name,\n size = \"small\",\n fixedWidth = false,\n ariaLabel,\n color,\n svgProps,\n ...rest\n}: TypeIconProps) => {\n if (includes(PartnerLogoNames, name)) {\n // Icon's \"default\" size is equivalent to PartnerLogo's \"small\" size\n const logoSize = size === \"default\" ? \"small\" : size;\n const logoProps = {\n partnerName: name,\n size: logoSize,\n logoType: \"symbol\" as const,\n svgProps,\n };\n return (\n <PartnerLogo\n // ariaLabel needs to be overridable by aria-label prop in ...rest\n aria-label={ariaLabel}\n {...rest}\n {...logoProps}\n />\n );\n }\n\n const defaultVariant = size === \"mini\" ? \"solid\" : \"outline\";\n\n const iconName: EnumIconSvgNames =\n // if not external and has no variant\n !name?.endsWith(\"-outline\") &&\n !name?.endsWith(\"-solid\") &&\n !includes(ExternalIconNames, name)\n ? // then add default variant\n `${name as EnumIconNamesWithoutVariants}-${defaultVariant}`\n : // else use name as is\n (name as EnumIconSvgNames);\n\n const iconViewBox = AllViewboxes[iconName];\n\n const { \"aria-label\": ariaLabelFromRest, ...restWithoutAriaLabel } = rest;\n const hasAriaLabel = !!ariaLabel || !!ariaLabelFromRest;\n const containerAriaProps = hasAriaLabel ? {} : { \"aria-hidden\": \"true\" };\n const svgAriaProps = hasAriaLabel\n ? { role: \"img\", \"aria-label\": ariaLabel ?? ariaLabelFromRest }\n : {};\n\n return (\n <Container\n iconSize={size}\n fixedWidth={!!fixedWidth}\n key={iconName}\n data-qa-icon={iconName}\n color={color}\n {...restWithoutAriaLabel}\n {...containerAriaProps}\n >\n <svg\n className=\"Icon-svg\"\n viewBox={iconViewBox}\n focusable={false}\n data-qa-icon-svg={`${iconName}-svg`}\n {...svgProps}\n {...svgAriaProps}\n >\n <use\n xmlnsXlink=\"http://www.w3.org/1999/xlink\"\n xlinkHref={`#seeds-svgs_${iconName}`}\n />\n </svg>\n </Container>\n );\n};\n\nconst ToggleableIcon = styled(Icon)<{ active: boolean }>`\n transition: all ${(p) => p.theme.duration.fast} linear;\n\n ${(p) =>\n p.active &&\n css`\n opacity: 1;\n transform: scale(1);\n `}\n\n ${(p) =>\n !p.active &&\n css`\n position: absolute;\n opacity: 0;\n transform: scale(0);\n `}\n`;\n\nconst IconToggle = ({\n activeName,\n inactiveName,\n isActive,\n size = \"small\",\n fixedWidth = false,\n ariaLabel,\n ...rest\n}: TypeToggleProps) => {\n return (\n <Box as=\"span\" position=\"relative\" display=\"inline-flex\" {...rest}>\n <ToggleableIcon\n active={isActive}\n name={activeName}\n size={size}\n fixedWidth={fixedWidth}\n aria-hidden={!isActive}\n aria-label={!isActive ? undefined : ariaLabel}\n />\n <ToggleableIcon\n active={!isActive}\n name={inactiveName}\n size={size}\n fixedWidth={fixedWidth}\n aria-hidden={isActive}\n aria-label={isActive ? ariaLabel : undefined}\n />\n </Box>\n );\n};\n\nIconToggle.displayName = \"Icon.Toggle\";\n/**\n * **Accessibility note:** It is best practice to wrap `<Icon.Toggle />` in a button. The button must include `aria-label` and `aria-pressed` in order for a screen reader to properly communicate the icon's state. See example below.\n *\n * @link https://www.w3.org/TR/wai-aria-practices-1.1/#button\n * @example\n * const [toggleState, setToggleState] = useState(false);\n * <Button // Wrap Icon.Toggle with Button\n * appearance='pill'\n * aria-label='like' // required for accessibility\n * aria-pressed={toggleState} // required for accessibility\n * onClick={() => setToggleState(!toggleState)}\n * >\n * <Icon.Toggle\n * activeName=\"heart-solid\"\n * inactiveName=\"heart-outline\"\n * isActive={toggleState}\n * />\n * </Button>\n */\nIcon.Toggle = IconToggle;\n\nexport default Icon;\n","import styled, { css } from \"styled-components\";\nimport { verticalAlign } from \"styled-system\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeIconSize } from \"./IconTypes\";\n\nconst sizes: { [key in TypeIconSize]: string } = {\n mini: \"12px\",\n\n /** TODO: deprecate default in favor of small in future release */\n default: \"16px\",\n small: \"16px\",\n medium: \"24px\",\n large: \"32px\",\n jumbo: \"64px\",\n};\n\nconst stylesForSize = (iconActualSize: string, fixedWidth: boolean) => css`\n line-height: ${iconActualSize};\n\n &,\n .Icon-svg {\n height: ${iconActualSize};\n fill: currentColor;\n }\n\n ${fixedWidth &&\n `\n &,\n & .Icon-svg {\n width: ${iconActualSize}\n }\n `}\n`;\n\nconst Container = styled.span.attrs({\n className: \"Icon\",\n})<{\n iconSize: TypeIconSize;\n fixedWidth: boolean;\n}>`\n display: inline-block;\n color: inherit;\n vertical-align: middle;\n\n ${(props) => stylesForSize(sizes[props.iconSize], props.fixedWidth)}\n\n ${COMMON}\n ${verticalAlign}\n`;\nexport default Container;\n","import * as React from \"react\";\nimport type { EnumIconNames } from \"@sproutsocial/seeds-icons\";\nimport type { EnumLogoNamesWithoutVariants } from \"@sproutsocial/seeds-partner-logos\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeBoxProps } from \"@sproutsocial/seeds-react-box\";\n\nexport type TypeIconName = EnumIconNames | EnumLogoNamesWithoutVariants;\n\nexport type TypeIconSize =\n | \"mini\" // 12x12\n // TODO: deprecate default in favor of small in future release\n | \"default\" // 16x16\n | \"small\" // 16x16\n | \"medium\" // 24x24\n | \"large\" // 32x32\n | \"jumbo\"; // 64x64\n\nexport interface TypeIconProps\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"span\">, \"color\"> {\n /** Name of the icon in the svg sprite */\n name: TypeIconName;\n size?: TypeIconSize;\n /** Whether the icon should have a fixed width or not. Use this when you need to align icons/text vertically in a list. */\n fixedWidth?: boolean;\n /** Label used to describe the icon if not used with an accompanying visual label */\n ariaLabel?: string;\n svgProps?: React.ComponentPropsWithoutRef<\"svg\">;\n}\n\nexport interface TypeToggleProps extends TypeBoxProps {\n /** Name of the icon to be shown in the active state */\n activeName: TypeIconName;\n /** Name of the icon to be shown in the inactive state */\n inactiveName: TypeIconName;\n /** Whether the active icon should be shown or not */\n isActive: boolean;\n /** The size of the icon. `small` is the default */\n size?: TypeIconSize;\n fixedWidth?: boolean;\n ariaLabel?: string;\n}\n","import * as React from \"react\";\nimport Container from \"./styles\";\nimport type { TypeIconV2Props } from \"./IconTypes\";\n\n/**\n * **Icon (v2)** — a structural wrapper that centers a caller-supplied SVG inside a\n * fixed-size container, slightly larger than the icon to give it breathing room\n * (a buffer against focus rings, hover backgrounds, and button padding).\n *\n * The caller passes the SVG directly via `children` (or the `icon` alias). The SVG\n * should use `viewBox=\"0 0 24 24\"` and `currentColor` fills — the component controls\n * only the rendered width/height and centering, never the viewBox or path-level fills.\n *\n * Sizes:\n * - `default` — 24×24px container, icon renders at 18×18px\n * - `small` — 20×20px container, icon renders at 15×15px\n *\n * Accessibility: decorative by default (`aria-hidden`). Pass `aria-label` to expose a\n * standalone icon — the container then gets `role=\"img\"` and the label.\n *\n * @example\n * <Icon aria-label=\"Settings\"><MySvg /></Icon>\n */\nconst Icon = React.forwardRef<HTMLSpanElement, TypeIconV2Props>(\n ({ size = \"default\", children, icon, \"aria-label\": ariaLabel, ...rest }, ref) => {\n const content = children ?? icon;\n const ariaProps = ariaLabel\n ? { role: \"img\" as const, \"aria-label\": ariaLabel }\n : { \"aria-hidden\": true };\n\n return (\n <Container\n ref={ref}\n iconSize={size}\n data-qa-icon-v2={size}\n {...ariaProps}\n {...rest}\n >\n {content}\n </Container>\n );\n }\n);\n\nIcon.displayName = \"IconV2\";\n\nexport default Icon;\n","import styled from \"styled-components\";\nimport { COMMON, FLEXBOX, LAYOUT } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeIconV2Size } from \"./IconTypes\";\n\nconst dimensions: { [key in TypeIconV2Size]: { container: string; icon: string } } = {\n default: { container: \"24px\", icon: \"18px\" },\n small: { container: \"20px\", icon: \"15px\" },\n};\n\n/**\n * Structural, non-semantic container that centers a caller-supplied SVG inside a\n * fixed-size box (slightly larger than the icon, for breathing room). The child\n * `svg` is sized via CSS to the icon dimensions and inherits color through\n * `currentColor` — no background or border.\n */\nconst Container = styled.span<{\n iconSize: TypeIconV2Size;\n}>`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n color: inherit;\n width: ${(props) => dimensions[props.iconSize].container};\n height: ${(props) => dimensions[props.iconSize].container};\n\n & > svg {\n width: ${(props) => dimensions[props.iconSize].icon};\n height: ${(props) => dimensions[props.iconSize].icon};\n flex-shrink: 0;\n fill: currentColor;\n }\n\n ${COMMON}\n ${FLEXBOX}\n ${LAYOUT}\n`;\n\nexport default Container;\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\n\nexport type TypeIconV2Size =\n | \"default\" // 24x24 container, 18x18 icon\n | \"small\"; // 20x20 container, 15x15 icon\n\nexport interface TypeIconV2Props\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"span\">, \"color\"> {\n /** Container/icon size variant. Defaults to `\"default\"` (24px container, 18px icon). */\n size?: TypeIconV2Size;\n /** The SVG element to render inside the container. Should use `viewBox=\"0 0 24 24\"` and `currentColor` fills. */\n children?: React.ReactNode;\n /** Alias for `children`. When both are provided, `children` wins. */\n icon?: React.ReactNode;\n /** When provided, the container gets `role=\"img\"` and this label, making a standalone icon accessible. Omit for decorative icons (the container is `aria-hidden` automatically). */\n \"aria-label\"?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAAA;AAAA,EAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,IAAAC,4BAA4B;AAC5B,6BAAgB;AAChB,sCAAwB;AACxB,mCAAyB;AACzB,iCAA6D;;;ACL7D,+BAA4B;AAC5B,2BAA8B;AAC9B,sCAAuB;AAGvB,IAAM,QAA2C;AAAA,EAC/C,MAAM;AAAA;AAAA,EAGN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;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AU;AAAA,QACV,mBAAiB;AAAA,QAChB,GAAG;AAAA,QACH,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEAD,MAAK,cAAc;AAEnB,IAAOE,gBAAQF;;;AE9Cf,IAAAG,SAAuB;;;ANEvB,IAAO,cAAQ;","names":["Icon_default","import_styled_components","styled","PartnerLogoNames","PartnerLogo","styled","Box","React","React","import_styled_components","import_seeds_react_system_props","Container","styled","styles_default","import_jsx_runtime","Icon","styles_default","Icon_default","React"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TypeStyledComponentsCommonProps, TypeSystemCommonProps } from '@sproutsocial/seeds-react-system-props';
|
|
3
|
+
|
|
4
|
+
type TypeIconV2Size = "default" | "small";
|
|
5
|
+
interface TypeIconV2Props extends TypeStyledComponentsCommonProps, TypeSystemCommonProps, Omit<React.ComponentPropsWithoutRef<"span">, "color"> {
|
|
6
|
+
/** Container/icon size variant. Defaults to `"default"` (24px container, 18px icon). */
|
|
7
|
+
size?: TypeIconV2Size;
|
|
8
|
+
/** The SVG element to render inside the container. Should use `viewBox="0 0 24 24"` and `currentColor` fills. */
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
/** Alias for `children`. When both are provided, `children` wins. */
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
/** When provided, the container gets `role="img"` and this label, making a standalone icon accessible. Omit for decorative icons (the container is `aria-hidden` automatically). */
|
|
13
|
+
"aria-label"?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* **Icon (v2)** — a structural wrapper that centers a caller-supplied SVG inside a
|
|
18
|
+
* fixed-size container, slightly larger than the icon to give it breathing room
|
|
19
|
+
* (a buffer against focus rings, hover backgrounds, and button padding).
|
|
20
|
+
*
|
|
21
|
+
* The caller passes the SVG directly via `children` (or the `icon` alias). The SVG
|
|
22
|
+
* should use `viewBox="0 0 24 24"` and `currentColor` fills — the component controls
|
|
23
|
+
* only the rendered width/height and centering, never the viewBox or path-level fills.
|
|
24
|
+
*
|
|
25
|
+
* Sizes:
|
|
26
|
+
* - `default` — 24×24px container, icon renders at 18×18px
|
|
27
|
+
* - `small` — 20×20px container, icon renders at 15×15px
|
|
28
|
+
*
|
|
29
|
+
* Accessibility: decorative by default (`aria-hidden`). Pass `aria-label` to expose a
|
|
30
|
+
* standalone icon — the container then gets `role="img"` and the label.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* <Icon aria-label="Settings"><MySvg /></Icon>
|
|
34
|
+
*/
|
|
35
|
+
declare const Icon: React.ForwardRefExoticComponent<Omit<TypeIconV2Props, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
36
|
+
|
|
37
|
+
export { Icon, type TypeIconV2Props, type TypeIconV2Size, Icon as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TypeStyledComponentsCommonProps, TypeSystemCommonProps } from '@sproutsocial/seeds-react-system-props';
|
|
3
|
+
|
|
4
|
+
type TypeIconV2Size = "default" | "small";
|
|
5
|
+
interface TypeIconV2Props extends TypeStyledComponentsCommonProps, TypeSystemCommonProps, Omit<React.ComponentPropsWithoutRef<"span">, "color"> {
|
|
6
|
+
/** Container/icon size variant. Defaults to `"default"` (24px container, 18px icon). */
|
|
7
|
+
size?: TypeIconV2Size;
|
|
8
|
+
/** The SVG element to render inside the container. Should use `viewBox="0 0 24 24"` and `currentColor` fills. */
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
/** Alias for `children`. When both are provided, `children` wins. */
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
/** When provided, the container gets `role="img"` and this label, making a standalone icon accessible. Omit for decorative icons (the container is `aria-hidden` automatically). */
|
|
13
|
+
"aria-label"?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* **Icon (v2)** — a structural wrapper that centers a caller-supplied SVG inside a
|
|
18
|
+
* fixed-size container, slightly larger than the icon to give it breathing room
|
|
19
|
+
* (a buffer against focus rings, hover backgrounds, and button padding).
|
|
20
|
+
*
|
|
21
|
+
* The caller passes the SVG directly via `children` (or the `icon` alias). The SVG
|
|
22
|
+
* should use `viewBox="0 0 24 24"` and `currentColor` fills — the component controls
|
|
23
|
+
* only the rendered width/height and centering, never the viewBox or path-level fills.
|
|
24
|
+
*
|
|
25
|
+
* Sizes:
|
|
26
|
+
* - `default` — 24×24px container, icon renders at 18×18px
|
|
27
|
+
* - `small` — 20×20px container, icon renders at 15×15px
|
|
28
|
+
*
|
|
29
|
+
* Accessibility: decorative by default (`aria-hidden`). Pass `aria-label` to expose a
|
|
30
|
+
* standalone icon — the container then gets `role="img"` and the label.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* <Icon aria-label="Settings"><MySvg /></Icon>
|
|
34
|
+
*/
|
|
35
|
+
declare const Icon: React.ForwardRefExoticComponent<Omit<TypeIconV2Props, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
36
|
+
|
|
37
|
+
export { Icon, type TypeIconV2Props, type TypeIconV2Size, Icon as default };
|
package/dist/v2/index.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/v2/index.ts
|
|
31
|
+
var v2_exports = {};
|
|
32
|
+
__export(v2_exports, {
|
|
33
|
+
Icon: () => Icon_default,
|
|
34
|
+
default: () => Icon_default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(v2_exports);
|
|
37
|
+
|
|
38
|
+
// src/v2/Icon.tsx
|
|
39
|
+
var React = __toESM(require("react"));
|
|
40
|
+
|
|
41
|
+
// src/v2/styles.ts
|
|
42
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
43
|
+
var import_seeds_react_system_props = require("@sproutsocial/seeds-react-system-props");
|
|
44
|
+
var dimensions = {
|
|
45
|
+
default: { container: "24px", icon: "18px" },
|
|
46
|
+
small: { container: "20px", icon: "15px" }
|
|
47
|
+
};
|
|
48
|
+
var Container = import_styled_components.default.span`
|
|
49
|
+
display: inline-flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
flex-shrink: 0;
|
|
53
|
+
color: inherit;
|
|
54
|
+
width: ${(props) => dimensions[props.iconSize].container};
|
|
55
|
+
height: ${(props) => dimensions[props.iconSize].container};
|
|
56
|
+
|
|
57
|
+
& > svg {
|
|
58
|
+
width: ${(props) => dimensions[props.iconSize].icon};
|
|
59
|
+
height: ${(props) => dimensions[props.iconSize].icon};
|
|
60
|
+
flex-shrink: 0;
|
|
61
|
+
fill: currentColor;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
${import_seeds_react_system_props.COMMON}
|
|
65
|
+
${import_seeds_react_system_props.FLEXBOX}
|
|
66
|
+
${import_seeds_react_system_props.LAYOUT}
|
|
67
|
+
`;
|
|
68
|
+
var styles_default = Container;
|
|
69
|
+
|
|
70
|
+
// src/v2/Icon.tsx
|
|
71
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
72
|
+
var Icon = React.forwardRef(
|
|
73
|
+
({ size = "default", children, icon, "aria-label": ariaLabel, ...rest }, ref) => {
|
|
74
|
+
const content = children ?? icon;
|
|
75
|
+
const ariaProps = ariaLabel ? { role: "img", "aria-label": ariaLabel } : { "aria-hidden": true };
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
77
|
+
styles_default,
|
|
78
|
+
{
|
|
79
|
+
ref,
|
|
80
|
+
iconSize: size,
|
|
81
|
+
"data-qa-icon-v2": size,
|
|
82
|
+
...ariaProps,
|
|
83
|
+
...rest,
|
|
84
|
+
children: content
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
Icon.displayName = "IconV2";
|
|
90
|
+
var Icon_default = Icon;
|
|
91
|
+
|
|
92
|
+
// src/v2/IconTypes.ts
|
|
93
|
+
var React2 = require("react");
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
Icon
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/v2/index.ts","../../src/v2/Icon.tsx","../../src/v2/styles.ts","../../src/v2/IconTypes.ts"],"sourcesContent":["// Icon v2 - Explicit named + default exports for optimal tree shaking\nexport { default, default as Icon } from \"./Icon\";\nexport * from \"./IconTypes\";\n","import * as React from \"react\";\nimport Container from \"./styles\";\nimport type { TypeIconV2Props } from \"./IconTypes\";\n\n/**\n * **Icon (v2)** — a structural wrapper that centers a caller-supplied SVG inside a\n * fixed-size container, slightly larger than the icon to give it breathing room\n * (a buffer against focus rings, hover backgrounds, and button padding).\n *\n * The caller passes the SVG directly via `children` (or the `icon` alias). The SVG\n * should use `viewBox=\"0 0 24 24\"` and `currentColor` fills — the component controls\n * only the rendered width/height and centering, never the viewBox or path-level fills.\n *\n * Sizes:\n * - `default` — 24×24px container, icon renders at 18×18px\n * - `small` — 20×20px container, icon renders at 15×15px\n *\n * Accessibility: decorative by default (`aria-hidden`). Pass `aria-label` to expose a\n * standalone icon — the container then gets `role=\"img\"` and the label.\n *\n * @example\n * <Icon aria-label=\"Settings\"><MySvg /></Icon>\n */\nconst Icon = React.forwardRef<HTMLSpanElement, TypeIconV2Props>(\n ({ size = \"default\", children, icon, \"aria-label\": ariaLabel, ...rest }, ref) => {\n const content = children ?? icon;\n const ariaProps = ariaLabel\n ? { role: \"img\" as const, \"aria-label\": ariaLabel }\n : { \"aria-hidden\": true };\n\n return (\n <Container\n ref={ref}\n iconSize={size}\n data-qa-icon-v2={size}\n {...ariaProps}\n {...rest}\n >\n {content}\n </Container>\n );\n }\n);\n\nIcon.displayName = \"IconV2\";\n\nexport default Icon;\n","import styled from \"styled-components\";\nimport { COMMON, FLEXBOX, LAYOUT } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeIconV2Size } from \"./IconTypes\";\n\nconst dimensions: { [key in TypeIconV2Size]: { container: string; icon: string } } = {\n default: { container: \"24px\", icon: \"18px\" },\n small: { container: \"20px\", icon: \"15px\" },\n};\n\n/**\n * Structural, non-semantic container that centers a caller-supplied SVG inside a\n * fixed-size box (slightly larger than the icon, for breathing room). The child\n * `svg` is sized via CSS to the icon dimensions and inherits color through\n * `currentColor` — no background or border.\n */\nconst Container = styled.span<{\n iconSize: TypeIconV2Size;\n}>`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n color: inherit;\n width: ${(props) => dimensions[props.iconSize].container};\n height: ${(props) => dimensions[props.iconSize].container};\n\n & > svg {\n width: ${(props) => dimensions[props.iconSize].icon};\n height: ${(props) => dimensions[props.iconSize].icon};\n flex-shrink: 0;\n fill: currentColor;\n }\n\n ${COMMON}\n ${FLEXBOX}\n ${LAYOUT}\n`;\n\nexport default Container;\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\n\nexport type TypeIconV2Size =\n | \"default\" // 24x24 container, 18x18 icon\n | \"small\"; // 20x20 container, 15x15 icon\n\nexport interface TypeIconV2Props\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"span\">, \"color\"> {\n /** Container/icon size variant. Defaults to `\"default\"` (24px container, 18px icon). */\n size?: TypeIconV2Size;\n /** The SVG element to render inside the container. Should use `viewBox=\"0 0 24 24\"` and `currentColor` fills. */\n children?: React.ReactNode;\n /** Alias for `children`. When both are provided, `children` wins. */\n icon?: React.ReactNode;\n /** When provided, the container gets `role=\"img\"` and this label, making a standalone icon accessible. Omit for decorative icons (the container is `aria-hidden` automatically). */\n \"aria-label\"?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;;;ACAvB,+BAAmB;AACnB,sCAAwC;AAGxC,IAAM,aAA+E;AAAA,EACnF,SAAS,EAAE,WAAW,QAAQ,MAAM,OAAO;AAAA,EAC3C,OAAO,EAAE,WAAW,QAAQ,MAAM,OAAO;AAC3C;AAQA,IAAM,YAAY,yBAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAQd,CAAC,UAAU,WAAW,MAAM,QAAQ,EAAE,SAAS;AAAA,YAC9C,CAAC,UAAU,WAAW,MAAM,QAAQ,EAAE,SAAS;AAAA;AAAA;AAAA,aAG9C,CAAC,UAAU,WAAW,MAAM,QAAQ,EAAE,IAAI;AAAA,cACzC,CAAC,UAAU,WAAW,MAAM,QAAQ,EAAE,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,IAKpD,sCAAM;AAAA,IACN,uCAAO;AAAA,IACP,sCAAM;AAAA;AAGV,IAAO,iBAAQ;;;ADPT;AARN,IAAM,OAAa;AAAA,EACjB,CAAC,EAAE,OAAO,WAAW,UAAU,MAAM,cAAc,WAAW,GAAG,KAAK,GAAG,QAAQ;AAC/E,UAAM,UAAU,YAAY;AAC5B,UAAM,YAAY,YACd,EAAE,MAAM,OAAgB,cAAc,UAAU,IAChD,EAAE,eAAe,KAAK;AAE1B,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,UAAU;AAAA,QACV,mBAAiB;AAAA,QAChB,GAAG;AAAA,QACH,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,KAAK,cAAc;AAEnB,IAAO,eAAQ;;;AE9Cf,IAAAC,SAAuB;","names":["styled","React"]}
|
package/package.json
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sproutsocial/seeds-react-icon",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Seeds React Icon component",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./v2": {
|
|
15
|
+
"types": "./dist/v2/index.d.ts",
|
|
16
|
+
"import": "./dist/esm/v2/index.js",
|
|
17
|
+
"require": "./dist/v2/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
8
20
|
"author": "Sprout Social, Inc.",
|
|
9
21
|
"license": "MIT",
|
|
10
22
|
"files": [
|
|
@@ -16,20 +28,27 @@
|
|
|
16
28
|
"dev": "tsup --watch --dts",
|
|
17
29
|
"clean": "rm -rf .turbo dist",
|
|
18
30
|
"clean:modules": "rm -rf node_modules",
|
|
19
|
-
"typecheck": "tsc --noEmit"
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"test": "jest",
|
|
33
|
+
"test:watch": "jest --watch --coverage=false"
|
|
20
34
|
},
|
|
21
35
|
"dependencies": {
|
|
22
|
-
"@sproutsocial/seeds-react-box": "^1.1.
|
|
23
|
-
"@sproutsocial/seeds-react-partner-logo": "^1.7.
|
|
24
|
-
"@sproutsocial/seeds-react-system-props": "^3.
|
|
25
|
-
"@sproutsocial/seeds-react-theme": "^
|
|
36
|
+
"@sproutsocial/seeds-react-box": "^1.1.21",
|
|
37
|
+
"@sproutsocial/seeds-react-partner-logo": "^1.7.13",
|
|
38
|
+
"@sproutsocial/seeds-react-system-props": "^3.1.1",
|
|
39
|
+
"@sproutsocial/seeds-react-theme": "^4.1.0",
|
|
26
40
|
"@sproutsocial/seeds-react-utilities": "^4.0.1",
|
|
27
41
|
"styled-system": "^5.1.5"
|
|
28
42
|
},
|
|
29
43
|
"devDependencies": {
|
|
30
44
|
"@sproutsocial/eslint-config-seeds": "*",
|
|
31
|
-
"@sproutsocial/seeds-icons": "^2.
|
|
32
|
-
"@sproutsocial/seeds-partner-logos": "^2.
|
|
45
|
+
"@sproutsocial/seeds-icons": "^2.9.0",
|
|
46
|
+
"@sproutsocial/seeds-partner-logos": "^2.4.1",
|
|
47
|
+
"@sproutsocial/seeds-react-testing-library": "*",
|
|
48
|
+
"@sproutsocial/seeds-testing": "*",
|
|
49
|
+
"@types/react": "^18.0.0",
|
|
50
|
+
"@types/styled-components": "^5.1.26",
|
|
51
|
+
"react": "^18.0.0",
|
|
33
52
|
"styled-components": "^5.2.3",
|
|
34
53
|
"typescript": "^5.6.2",
|
|
35
54
|
"tsup": "^8.3.4",
|