@tanishqkancharla/maui 0.0.48 → 0.0.49
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/components/LogoIcon.d.ts +12 -0
- package/dist/components/LogoIcon.js +19 -0
- package/dist/maui.d.ts +1 -0
- package/dist/maui.js +1 -0
- package/package.json +1 -1
- package/src/components/LogoIcon.test.tsx +30 -0
- package/src/components/LogoIcon.tsx +35 -0
- package/src/maui.ts +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type IconSize } from "../tokens/sizing";
|
|
2
|
+
export type LogoIconProps = {
|
|
3
|
+
src: string;
|
|
4
|
+
size?: IconSize;
|
|
5
|
+
alt?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Brand artwork in an icon-sized box. Defaults to md (18px, or 24px at Large
|
|
9
|
+
* scale). Padding is included in the box and scales with it: 2px at 18px.
|
|
10
|
+
* An empty alt makes the logo decorative; provide alt for standalone images.
|
|
11
|
+
*/
|
|
12
|
+
export declare function LogoIcon({ src, size, alt }: LogoIconProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { style, useStyles } from "purse-styles";
|
|
3
|
+
import { iconSizeValues } from "../tokens/sizing";
|
|
4
|
+
/**
|
|
5
|
+
* Brand artwork in an icon-sized box. Defaults to md (18px, or 24px at Large
|
|
6
|
+
* scale). Padding is included in the box and scales with it: 2px at 18px.
|
|
7
|
+
* An empty alt makes the logo decorative; provide alt for standalone images.
|
|
8
|
+
*/
|
|
9
|
+
export function LogoIcon({ src, size = "md", alt = "" }) {
|
|
10
|
+
const className = useStyles(logo);
|
|
11
|
+
const box = iconSizeValues[size];
|
|
12
|
+
return (_jsx("img", { src: src, alt: alt, "aria-hidden": alt === "" ? true : undefined, className: className, style: { width: box, height: box, padding: `calc(${box} / 9)` } }));
|
|
13
|
+
}
|
|
14
|
+
const logo = style({
|
|
15
|
+
display: "block",
|
|
16
|
+
boxSizing: "border-box",
|
|
17
|
+
objectFit: "contain",
|
|
18
|
+
flexShrink: 0,
|
|
19
|
+
});
|
package/dist/maui.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { prose, proseRhythm, proseHtml, proseStreamingMarkers, type ProseSize, }
|
|
|
20
20
|
export { visuallyHidden } from "./tokens/visuallyHidden";
|
|
21
21
|
export { Avatar } from "./components/Avatar";
|
|
22
22
|
export { Badge } from "./components/Badge";
|
|
23
|
+
export { LogoIcon, type LogoIconProps } from "./components/LogoIcon";
|
|
23
24
|
export { Button, useButton, type ButtonCssColor, type ButtonProps, type ButtonSize, type ButtonVariant, type ButtonVariantColor, } from "./components/Button";
|
|
24
25
|
export { TabBar, type TabBarItem, type TabBarProps, } from "./components/TabBar";
|
|
25
26
|
export { Checkbox } from "./components/Checkbox";
|
package/dist/maui.js
CHANGED
|
@@ -23,6 +23,7 @@ export { visuallyHidden } from "./tokens/visuallyHidden";
|
|
|
23
23
|
// Components
|
|
24
24
|
export { Avatar } from "./components/Avatar";
|
|
25
25
|
export { Badge } from "./components/Badge";
|
|
26
|
+
export { LogoIcon } from "./components/LogoIcon";
|
|
26
27
|
export { Button, useButton, } from "./components/Button";
|
|
27
28
|
export { TabBar, } from "./components/TabBar";
|
|
28
29
|
export { Checkbox } from "./components/Checkbox";
|
package/package.json
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from "react-dom/server"
|
|
2
|
+
import { PurseProvider } from "purse-styles"
|
|
3
|
+
import { afterAll, beforeAll, expect, it, vi } from "vitest"
|
|
4
|
+
import { LogoIcon } from "./LogoIcon"
|
|
5
|
+
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
vi.stubGlobal("document", { createElement: () => ({}) })
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
afterAll(() => {
|
|
11
|
+
vi.unstubAllGlobals()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it("is decorative by default and exposes an accessible name when provided", () => {
|
|
15
|
+
const decorative = renderToStaticMarkup(
|
|
16
|
+
<PurseProvider>
|
|
17
|
+
<LogoIcon src="/brand.svg" />
|
|
18
|
+
</PurseProvider>,
|
|
19
|
+
)
|
|
20
|
+
expect(decorative).toContain('alt=""')
|
|
21
|
+
expect(decorative).toContain('aria-hidden="true"')
|
|
22
|
+
|
|
23
|
+
const labeled = renderToStaticMarkup(
|
|
24
|
+
<PurseProvider>
|
|
25
|
+
<LogoIcon src="/brand.svg" alt="Example" />
|
|
26
|
+
</PurseProvider>,
|
|
27
|
+
)
|
|
28
|
+
expect(labeled).toContain('alt="Example"')
|
|
29
|
+
expect(labeled).not.toContain("aria-hidden")
|
|
30
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { style, useStyles } from "purse-styles"
|
|
2
|
+
import { iconSizeValues, type IconSize } from "../tokens/sizing"
|
|
3
|
+
|
|
4
|
+
export type LogoIconProps = {
|
|
5
|
+
src: string
|
|
6
|
+
size?: IconSize
|
|
7
|
+
alt?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Brand artwork in an icon-sized box. Defaults to md (18px, or 24px at Large
|
|
12
|
+
* scale). Padding is included in the box and scales with it: 2px at 18px.
|
|
13
|
+
* An empty alt makes the logo decorative; provide alt for standalone images.
|
|
14
|
+
*/
|
|
15
|
+
export function LogoIcon({ src, size = "md", alt = "" }: LogoIconProps) {
|
|
16
|
+
const className = useStyles(logo)
|
|
17
|
+
const box = iconSizeValues[size]
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<img
|
|
21
|
+
src={src}
|
|
22
|
+
alt={alt}
|
|
23
|
+
aria-hidden={alt === "" ? true : undefined}
|
|
24
|
+
className={className}
|
|
25
|
+
style={{ width: box, height: box, padding: `calc(${box} / 9)` }}
|
|
26
|
+
/>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const logo = style({
|
|
31
|
+
display: "block",
|
|
32
|
+
boxSizing: "border-box",
|
|
33
|
+
objectFit: "contain",
|
|
34
|
+
flexShrink: 0,
|
|
35
|
+
})
|
package/src/maui.ts
CHANGED
|
@@ -57,6 +57,7 @@ export { visuallyHidden } from "./tokens/visuallyHidden"
|
|
|
57
57
|
// Components
|
|
58
58
|
export { Avatar } from "./components/Avatar"
|
|
59
59
|
export { Badge } from "./components/Badge"
|
|
60
|
+
export { LogoIcon, type LogoIconProps } from "./components/LogoIcon"
|
|
60
61
|
export {
|
|
61
62
|
Button,
|
|
62
63
|
useButton,
|