|
| 1 | +import type { Meta, StoryObj } from "@storybook/react" |
| 2 | + |
| 3 | +import { DefaultFacet } from "@/components/search/DefaultFacet" |
| 4 | +import { FairDOConfigBuilder } from "@/config/FairDOConfigBuilder" |
| 5 | +import { TooltipProvider } from "@/components/ui/tooltip" |
| 6 | +import { GlobalModalProvider } from "@/components/GlobalModalProvider" |
| 7 | +import { GenericResultView } from "@/components/result" |
| 8 | +import type { FairDOConfig } from "@/config/FairDOConfig" |
| 9 | + |
| 10 | +const meta = { |
| 11 | + component: DefaultFacet |
| 12 | +} satisfies Meta<typeof DefaultFacet> |
| 13 | + |
| 14 | +export default meta |
| 15 | + |
| 16 | +const demoConfig: FairDOConfig = { |
| 17 | + debug: false, |
| 18 | + alwaysSearchOnInitialLoad: true, |
| 19 | + // host: "https://matwerk.datamanager.kit.edu/search-proxy/api/v1", |
| 20 | + host: "", |
| 21 | + apiKey: "", |
| 22 | + indices: [ |
| 23 | + { |
| 24 | + name: "fdo-prod", |
| 25 | + facets: [ |
| 26 | + { label: "My Facet", key: "facet1" }, |
| 27 | + { label: "Pretty URLs", key: "facet2", prettyPrintURLs: true }, |
| 28 | + { label: "With Pid Resolver", key: "facet3", usePidResolver: true } |
| 29 | + ], |
| 30 | + resultFields: [], // Leave empty to get all fields |
| 31 | + searchFields: [] |
| 32 | + } |
| 33 | + ] |
| 34 | +} |
| 35 | + |
| 36 | +type Story = StoryObj<typeof meta> |
| 37 | + |
| 38 | +export const Default: Story = { |
| 39 | + decorators: [ |
| 40 | + (Story) => ( |
| 41 | + <TooltipProvider> |
| 42 | + <GlobalModalProvider resultView={GenericResultView}> |
| 43 | + <div className="rfs-max-w-60"> |
| 44 | + <Story /> |
| 45 | + </div> |
| 46 | + </GlobalModalProvider> |
| 47 | + </TooltipProvider> |
| 48 | + ) |
| 49 | + ], |
| 50 | + args: { |
| 51 | + label: "My Facet", |
| 52 | + onMoreClick: () => {}, |
| 53 | + onRemove: () => {}, |
| 54 | + onChange: () => {}, |
| 55 | + onSelect: () => {}, |
| 56 | + options: [ |
| 57 | + { count: 10, value: "First entry" }, |
| 58 | + { count: 20, value: "Second entry" }, |
| 59 | + { count: 30, value: "Third entry" }, |
| 60 | + { count: 42, value: "Fourth entry" } |
| 61 | + ], |
| 62 | + showMore: false, |
| 63 | + values: [], |
| 64 | + showSearch: false, |
| 65 | + onSearch: () => {}, |
| 66 | + searchPlaceholder: "", |
| 67 | + config: new FairDOConfigBuilder(demoConfig) |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +export const PrettyURL: Story = { |
| 72 | + decorators: [ |
| 73 | + (Story) => ( |
| 74 | + <TooltipProvider> |
| 75 | + <GlobalModalProvider resultView={GenericResultView}> |
| 76 | + <div className="rfs-max-w-60"> |
| 77 | + <Story /> |
| 78 | + </div> |
| 79 | + </GlobalModalProvider> |
| 80 | + </TooltipProvider> |
| 81 | + ) |
| 82 | + ], |
| 83 | + args: { |
| 84 | + label: "Pretty URLs", |
| 85 | + onMoreClick: () => {}, |
| 86 | + onRemove: () => {}, |
| 87 | + onChange: () => {}, |
| 88 | + onSelect: () => {}, |
| 89 | + options: [ |
| 90 | + { count: 10, value: "https://kit.edu/test" }, |
| 91 | + { count: 20, value: "https://www.example.org/" } |
| 92 | + ], |
| 93 | + showMore: false, |
| 94 | + values: [], |
| 95 | + showSearch: false, |
| 96 | + onSearch: () => {}, |
| 97 | + searchPlaceholder: "", |
| 98 | + config: new FairDOConfigBuilder(demoConfig) |
| 99 | + } |
| 100 | +} |
| 101 | + |
| 102 | +export const WithPidResolver: Story = { |
| 103 | + decorators: [ |
| 104 | + (Story) => ( |
| 105 | + <TooltipProvider> |
| 106 | + <GlobalModalProvider resultView={GenericResultView}> |
| 107 | + <div className="rfs-max-w-60"> |
| 108 | + <Story /> |
| 109 | + </div> |
| 110 | + </GlobalModalProvider> |
| 111 | + </TooltipProvider> |
| 112 | + ) |
| 113 | + ], |
| 114 | + args: { |
| 115 | + label: "With Pid Resolver", |
| 116 | + onMoreClick: () => {}, |
| 117 | + onRemove: () => {}, |
| 118 | + onChange: () => {}, |
| 119 | + onSelect: () => {}, |
| 120 | + options: [ |
| 121 | + { count: 10, value: "21.T11148/010acb220a9c2c8c0ee6" }, |
| 122 | + { count: 20, value: "21.T11148/ca9fd0b2414177b79ac2" } |
| 123 | + ], |
| 124 | + showMore: false, |
| 125 | + values: [], |
| 126 | + showSearch: false, |
| 127 | + onSearch: () => {}, |
| 128 | + searchPlaceholder: "", |
| 129 | + config: new FairDOConfigBuilder(demoConfig) |
| 130 | + } |
| 131 | +} |
0 commit comments