@petercoxhatesbridges/extension-ui 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +82 -2
  2. package/dist/Button.d.ts +10 -0
  3. package/dist/Button.d.ts.map +1 -0
  4. package/dist/Button.js +15 -0
  5. package/dist/Button.js.map +1 -0
  6. package/dist/ExtensionShell.d.ts +40 -0
  7. package/dist/ExtensionShell.d.ts.map +1 -0
  8. package/dist/ExtensionShell.js +17 -0
  9. package/dist/ExtensionShell.js.map +1 -0
  10. package/dist/FilterListEditor.d.ts +13 -0
  11. package/dist/FilterListEditor.d.ts.map +1 -0
  12. package/dist/FilterListEditor.js +22 -0
  13. package/dist/FilterListEditor.js.map +1 -0
  14. package/dist/InfoBanner.d.ts +6 -0
  15. package/dist/InfoBanner.d.ts.map +1 -0
  16. package/dist/InfoBanner.js +5 -0
  17. package/dist/InfoBanner.js.map +1 -0
  18. package/dist/Input.d.ts +3 -0
  19. package/dist/Input.d.ts.map +1 -0
  20. package/dist/Input.js +5 -0
  21. package/dist/Input.js.map +1 -0
  22. package/dist/Preferences.d.ts +9 -0
  23. package/dist/Preferences.d.ts.map +1 -0
  24. package/dist/Preferences.js +21 -0
  25. package/dist/Preferences.js.map +1 -0
  26. package/dist/SettingsSection.d.ts +8 -0
  27. package/dist/SettingsSection.d.ts.map +1 -0
  28. package/dist/SettingsSection.js +8 -0
  29. package/dist/SettingsSection.js.map +1 -0
  30. package/dist/ShowHide.d.ts +6 -0
  31. package/dist/ShowHide.d.ts.map +1 -0
  32. package/dist/ShowHide.js +11 -0
  33. package/dist/ShowHide.js.map +1 -0
  34. package/dist/Switch.d.ts +10 -0
  35. package/dist/Switch.d.ts.map +1 -0
  36. package/dist/Switch.js +13 -0
  37. package/dist/Switch.js.map +1 -0
  38. package/dist/Tabs.d.ts +7 -0
  39. package/dist/Tabs.d.ts.map +1 -0
  40. package/dist/Tabs.js +15 -0
  41. package/dist/Tabs.js.map +1 -0
  42. package/dist/index.d.ts +11 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +11 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/styles.css +746 -0
  47. package/package.json +51 -4
  48. package/stories/Controls.stories.tsx +70 -0
  49. package/stories/ExtensionShell.stories.tsx +120 -0
  50. package/stories/FilterListEditor.stories.tsx +64 -0
  51. package/stories/Preferences.stories.tsx +84 -0
  52. package/stories/input.stories.tsx +18 -0
  53. package/stories/switch.stories.tsx +32 -0
  54. package/stories/tabs.stories.tsx +30 -0
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@petercoxhatesbridges/extension-ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Shared React controls and preferences UI for Chrome extensions",
5
+ "type": "module",
6
+ "files": [
7
+ "dist",
8
+ "stories",
9
+ "README.md"
10
+ ],
11
+ "sideEffects": [
12
+ "**/*.css"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/PeterWCox/shared.git",
17
+ "directory": "packages/extension-ui"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public",
21
+ "registry": "https://registry.npmjs.org"
22
+ },
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js"
27
+ },
28
+ "./styles.css": "./dist/styles.css",
29
+ "./stories/*": "./stories/*"
30
+ },
31
+ "peerDependencies": {
32
+ "react": "^19.0.0",
33
+ "react-dom": "^19.0.0"
34
+ },
35
+ "dependencies": {
36
+ "@radix-ui/react-tabs": "^1.1.21"
37
+ },
38
+ "devDependencies": {
39
+ "@types/react": "^19.0.0",
40
+ "@types/react-dom": "^19.0.0",
41
+ "react": "^19.0.0",
42
+ "react-dom": "^19.0.0",
43
+ "@testing-library/react": "^16.3.2",
44
+ "@testing-library/user-event": "^14.6.1",
45
+ "happy-dom": "^20.11.1"
46
+ },
47
+ "scripts": {
48
+ "build": "tsc -p tsconfig.build.json && cp src/styles.css dist/styles.css",
49
+ "typecheck": "tsc --noEmit",
50
+ "test": "bun test",
51
+ "prepack": "bun run build"
52
+ }
53
+ }
@@ -0,0 +1,70 @@
1
+ import * as React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react-vite";
3
+ import { useState } from "react";
4
+ import { expect, userEvent } from "storybook/test";
5
+ import { Button, Input, Switch, ShowHide } from "../dist/index.js";
6
+ import "../dist/styles.css";
7
+ const meta = {
8
+ title: "Extension UI/Controls",
9
+ component: Button,
10
+ } satisfies Meta<typeof Button>;
11
+ export default meta;
12
+ type Story = StoryObj<typeof meta>;
13
+ export const Buttons: Story = {
14
+ render: () => (
15
+ <div style={{ display: "flex", gap: 12 }}>
16
+ <Button>Continue</Button>
17
+ <Button variant="outline">Secondary</Button>
18
+ <Button variant="ghost" size="small">
19
+ Dismiss
20
+ </Button>
21
+ <Button size="icon" aria-label="Add">
22
+ +
23
+ </Button>
24
+ <Button disabled>Disabled</Button>
25
+ </div>
26
+ ),
27
+ };
28
+ export const InputsAndSwitches: Story = {
29
+ render: function Controls() {
30
+ const [checked, setChecked] = useState(false);
31
+ return (
32
+ <div style={{ display: "grid", gap: 12, maxWidth: 360 }}>
33
+ <Input aria-label="Search" placeholder="Search filters" />
34
+ <Switch
35
+ label="Enable filtering"
36
+ checked={checked}
37
+ onCheckedChange={setChecked}
38
+ />
39
+ <Switch size="lg" checked aria-label="Large switch" />
40
+ <Switch disabled aria-label="Disabled switch" />
41
+ </div>
42
+ );
43
+ },
44
+ play: async ({ canvas }) => {
45
+ await userEvent.click(
46
+ canvas.getByRole("switch", { name: "Enable filtering" }),
47
+ );
48
+ await expect(
49
+ canvas.getByRole("switch", { name: "Enable filtering" }),
50
+ ).toHaveAttribute("aria-checked", "true");
51
+ },
52
+ };
53
+ export const Visibility: Story = {
54
+ render: function Visibility() {
55
+ const [hidden, setHidden] = useState(false);
56
+ return (
57
+ <ShowHide
58
+ label="Remote"
59
+ hidden={hidden}
60
+ onChange={() => setHidden(!hidden)}
61
+ />
62
+ );
63
+ },
64
+ play: async ({ canvas }) => {
65
+ await userEvent.click(canvas.getByRole("button", { name: "Hide Remote" }));
66
+ await expect(
67
+ canvas.getByRole("button", { name: "Hide Remote" }),
68
+ ).toHaveAttribute("aria-pressed", "true");
69
+ },
70
+ };
@@ -0,0 +1,120 @@
1
+ import * as React from "react";
2
+ import { useState } from "react";
3
+ import type { Meta, StoryObj } from "@storybook/react-vite";
4
+ import { expect, userEvent } from "storybook/test";
5
+ import {
6
+ ExtensionShell,
7
+ TabsContent,
8
+ FilterListEditor,
9
+ SettingsSection,
10
+ SaveStatus,
11
+ InfoBanner,
12
+ Button,
13
+ } from "../dist/index.js";
14
+ import "../dist/styles.css";
15
+ const meta = {
16
+ title: "Extension UI/Extension shell",
17
+ component: ExtensionShell,
18
+ parameters: { layout: "fullscreen" },
19
+ } satisfies Meta<typeof ExtensionShell>;
20
+ export default meta;
21
+ type Story = StoryObj;
22
+ const tabs = [
23
+ {
24
+ id: "filters",
25
+ label: "Filters",
26
+ description: "Hide jobs matching your custom filters.",
27
+ icon: <span aria-hidden="true">T</span>,
28
+ },
29
+ {
30
+ id: "settings",
31
+ label: "Settings",
32
+ secondary: true,
33
+ icon: <span aria-hidden="true">⚙</span>,
34
+ },
35
+ ];
36
+ export const ConfiguredShell: Story = {
37
+ render: function Shell() {
38
+ const [active, setActive] = useState("filters");
39
+ const [values, setValues] = useState(["Graduate"]);
40
+ return (
41
+ <ExtensionShell
42
+ branding={{
43
+ name: "My extension",
44
+ subtitle: "Consumer-supplied branding",
45
+ logo: (
46
+ <span className="brand-asset" aria-hidden="true">
47
+ ◆
48
+ </span>
49
+ ),
50
+ }}
51
+ version="1.0.0"
52
+ beta
53
+ tabs={tabs}
54
+ activeTab={active}
55
+ onTabChange={setActive}
56
+ footerLinks={[
57
+ { href: "https://example.com/review", label: "Leave a review" },
58
+ { href: "https://example.com/about", label: "About me" },
59
+ ]}
60
+ style={{ height: 600, width: 480, maxWidth: "100%" }}
61
+ >
62
+ <TabsContent value="filters">
63
+ <FilterListEditor
64
+ values={values}
65
+ inputLabel="Keyword"
66
+ onAdd={(value) => setValues([...values, value])}
67
+ onRemove={(value) => setValues(values.filter((v) => v !== value))}
68
+ />
69
+ </TabsContent>
70
+ <TabsContent value="settings">
71
+ <SettingsSection
72
+ title="Backup preferences"
73
+ description="Save or restore your filters."
74
+ >
75
+ <Button variant="outline">Export</Button>
76
+ </SettingsSection>
77
+ </TabsContent>
78
+ </ExtensionShell>
79
+ );
80
+ },
81
+ play: async ({ canvas }) => {
82
+ await expect(canvas.getByLabelText("Beta build")).toBeInTheDocument();
83
+ await userEvent.click(canvas.getByRole("tab", { name: "Settings" }));
84
+ await expect(
85
+ canvas.getByRole("heading", { name: "Backup preferences" }),
86
+ ).toBeInTheDocument();
87
+ },
88
+ };
89
+ export const LoadingAndSaveError: Story = {
90
+ render: () => (
91
+ <ExtensionShell
92
+ version="1.0.0"
93
+ footerLinks={[{ href: "https://example.com/about", label: "About me" }]}
94
+ branding={{ name: "My extension" }}
95
+ tabs={tabs}
96
+ activeTab="filters"
97
+ onTabChange={() => {}}
98
+ loading
99
+ status="Could not save preferences. Please try again."
100
+ style={{ height: 600 }}
101
+ />
102
+ ),
103
+ };
104
+ export const InformationAndFeedback: Story = {
105
+ render: () => (
106
+ <div style={{ padding: 16, maxWidth: 480, fontFamily: "system-ui" }}>
107
+ <InfoBanner>
108
+ Jobs with application methods set to Hide will be hidden in your
109
+ LinkedIn job search results.
110
+ </InfoBanner>
111
+ <SettingsSection
112
+ title="Backup preferences"
113
+ description="Save your preferences to a file, or restore a backup."
114
+ >
115
+ <Button variant="outline">Export</Button>
116
+ </SettingsSection>
117
+ <SaveStatus>Saved</SaveStatus>
118
+ </div>
119
+ ),
120
+ };
@@ -0,0 +1,64 @@
1
+ import * as React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react-vite";
3
+ import { useState } from "react";
4
+ import { expect, userEvent } from "storybook/test";
5
+ import { FilterListEditor } from "../dist/index.js";
6
+ import "../dist/styles.css";
7
+ const meta = {
8
+ title: "Extension UI/Filter list editor",
9
+ component: FilterListEditor,
10
+ args: {
11
+ inputLabel: "Title keyword",
12
+ placeholder: "e.g. Graduate, Java",
13
+ emptyText: "No title keywords yet.",
14
+ },
15
+ } satisfies Meta<typeof FilterListEditor>;
16
+ export default meta;
17
+ type Story = StoryObj;
18
+ export const Interactive: Story = {
19
+ render: function Editor(args) {
20
+ const [values, setValues] = useState(["Ruby", "Graduate"]);
21
+ return (
22
+ <FilterListEditor
23
+ {...args}
24
+ values={values}
25
+ onAdd={(value) => setValues([...values, value])}
26
+ onRemove={(value) => setValues(values.filter((v) => v !== value))}
27
+ />
28
+ );
29
+ },
30
+ play: async ({ canvas }) => {
31
+ await userEvent.type(canvas.getByRole("textbox"), "Java{Enter}");
32
+ await expect(
33
+ canvas.getByRole("button", { name: "Remove Java" }),
34
+ ).toBeInTheDocument();
35
+ await userEvent.click(canvas.getByRole("button", { name: "Remove Java" }));
36
+ await expect(
37
+ canvas.queryByRole("button", { name: "Remove Java" }),
38
+ ).not.toBeInTheDocument();
39
+ },
40
+ };
41
+ export const Empty: Story = {
42
+ render: (args) => (
43
+ <FilterListEditor
44
+ {...args}
45
+ values={[]}
46
+ onAdd={() => {}}
47
+ onRemove={() => {}}
48
+ />
49
+ ),
50
+ };
51
+ export const LongValues: Story = {
52
+ render: (args) => (
53
+ <div style={{ width: 280 }}>
54
+ <FilterListEditor
55
+ {...args}
56
+ values={[
57
+ "A very long custom title filter that must wrap in a narrow extension popup",
58
+ ]}
59
+ onAdd={() => {}}
60
+ onRemove={() => {}}
61
+ />
62
+ </div>
63
+ ),
64
+ };
@@ -0,0 +1,84 @@
1
+ import * as React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react-vite";
3
+ import { useState } from "react";
4
+ import { expect, userEvent } from "storybook/test";
5
+ import {
6
+ PreferencesShell,
7
+ PreferencesHeader,
8
+ PreferencesLayout,
9
+ PreferencesNavigation,
10
+ PreferencesContent,
11
+ PreferencesFooter,
12
+ TabsList,
13
+ TabsTrigger,
14
+ TabsContent,
15
+ FilterListEditor,
16
+ } from "../dist/index.js";
17
+ import "../dist/styles.css";
18
+ const meta = {
19
+ title: "Extension UI/Preferences",
20
+ parameters: { layout: "fullscreen" },
21
+ } satisfies Meta;
22
+ export default meta;
23
+ type Story = StoryObj<typeof meta>;
24
+ export const BrandedLayout: Story = {
25
+ render: function Layout() {
26
+ const [values, setValues] = useState(["Graduate"]);
27
+ return (
28
+ <PreferencesShell
29
+ defaultValue="filters"
30
+ style={{ height: 600, width: 480, maxWidth: "100%" }}
31
+ >
32
+ <PreferencesHeader>
33
+ <div className="brand-wordmark">
34
+ <strong>My extension</strong>
35
+ <span>Custom branding slot</span>
36
+ </div>
37
+ </PreferencesHeader>
38
+ <PreferencesLayout>
39
+ <PreferencesNavigation>
40
+ <TabsList
41
+ className="preferences-tabs-list"
42
+ aria-label="Preference sections"
43
+ >
44
+ <TabsTrigger className="preferences-tab" value="filters">
45
+ Filters
46
+ </TabsTrigger>
47
+ <TabsTrigger className="preferences-tab" value="settings">
48
+ Settings
49
+ </TabsTrigger>
50
+ </TabsList>
51
+ </PreferencesNavigation>
52
+ <PreferencesContent>
53
+ <TabsContent value="filters">
54
+ <div className="preferences-content-heading">
55
+ <h1>Filters</h1>
56
+ </div>
57
+ <p className="preferences-info">
58
+ Hide jobs matching these title keywords.
59
+ </p>
60
+ <FilterListEditor
61
+ values={values}
62
+ inputLabel="Title keyword"
63
+ onAdd={(value) => setValues([...values, value])}
64
+ onRemove={(value) =>
65
+ setValues(values.filter((v) => v !== value))
66
+ }
67
+ />
68
+ </TabsContent>
69
+ <TabsContent value="settings">
70
+ Extension-specific settings
71
+ </TabsContent>
72
+ </PreferencesContent>
73
+ <PreferencesFooter>Extension-specific links</PreferencesFooter>
74
+ </PreferencesLayout>
75
+ </PreferencesShell>
76
+ );
77
+ },
78
+ play: async ({ canvas }) => {
79
+ await userEvent.click(canvas.getByRole("tab", { name: "Settings" }));
80
+ await expect(canvas.getByRole("tabpanel")).toHaveTextContent(
81
+ "Extension-specific settings",
82
+ );
83
+ },
84
+ };
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import "../dist/styles.css";
3
+ import type { Meta, StoryObj } from "@storybook/react-vite";
4
+ import { Input } from "../dist/index.js";
5
+
6
+ const meta = { title: "Extension UI/input" } satisfies Meta<typeof Input>;
7
+ export default meta;
8
+ type Story = StoryObj<typeof meta>;
9
+
10
+ export const States: Story = {
11
+ render: () => (
12
+ <div style={{ display: "grid", gap: 12, maxWidth: 360 }}>
13
+ <Input placeholder="Search jobs" aria-label="Search jobs" />
14
+ <Input value="TypeScript" readOnly aria-label="Entered value" />
15
+ <Input placeholder="Disabled" disabled aria-label="Disabled input" />
16
+ </div>
17
+ ),
18
+ };
@@ -0,0 +1,32 @@
1
+ import * as React from "react";
2
+ import "../dist/styles.css";
3
+ import type { Meta, StoryObj } from "@storybook/react-vite";
4
+ import { useState } from "react";
5
+ import { Switch } from "../dist/index.js";
6
+
7
+ const meta = { title: "Extension UI/switch" } satisfies Meta<typeof Switch>;
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+
11
+ export const Interactive: Story = {
12
+ render: () => {
13
+ const [checked, setChecked] = useState(false);
14
+ return (
15
+ <Switch
16
+ checked={checked}
17
+ onCheckedChange={setChecked}
18
+ aria-label="Enable setting"
19
+ />
20
+ );
21
+ },
22
+ };
23
+
24
+ export const WithLabel: Story = {
25
+ render: () => (
26
+ <Switch
27
+ aria-label="Enable notifications"
28
+ label="Enable notifications"
29
+ checked
30
+ />
31
+ ),
32
+ };
@@ -0,0 +1,30 @@
1
+ import * as React from "react";
2
+ import "../dist/styles.css";
3
+ import { expect, userEvent } from "storybook/test";
4
+ import type { Meta, StoryObj } from "@storybook/react-vite";
5
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from "../dist/index.js";
6
+
7
+ const meta = { title: "Extension UI/tabs" } satisfies Meta;
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+
11
+ export const Default: Story = {
12
+ render: () => (
13
+ <Tabs defaultValue="signals" style={{ maxWidth: 420 }}>
14
+ <TabsList>
15
+ <TabsTrigger value="signals">Signals</TabsTrigger>
16
+ <TabsTrigger value="settings">Settings</TabsTrigger>
17
+ </TabsList>
18
+ <TabsContent value="signals">Signals found in this job.</TabsContent>
19
+ <TabsContent value="settings">Extension preferences.</TabsContent>
20
+ </Tabs>
21
+ ),
22
+ play: async ({ canvas }) => {
23
+ await userEvent.click(canvas.getByRole("tab", { name: "Signals" }));
24
+ await userEvent.keyboard("{ArrowRight}");
25
+ await expect(canvas.getByRole("tab", { name: "Settings" })).toHaveAttribute(
26
+ "aria-selected",
27
+ "true",
28
+ );
29
+ },
30
+ };