Skip to content

Commit

Permalink
fix: remove duplicate template code
Browse files Browse the repository at this point in the history
  • Loading branch information
mdt2 committed May 22, 2024
1 parent 2c5aac6 commit fe34cdf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 38 deletions.
5 changes: 3 additions & 2 deletions components/popover/stories/popover.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { userEvent, within } from "@storybook/testing-library";
import { html } from "lit";
import { when } from "lit/directives/when.js";

import { SourcelessTemplate, Template } from "./template";
import { Template } from "./template";

import { Template as ActionButton } from "@spectrum-css/actionbutton/stories/template.js";
import { Template as Menu } from "@spectrum-css/menu/stories/template.js";
Expand Down Expand Up @@ -168,10 +168,11 @@ const ChromaticTipPlacementVariants = (args) => html`
`)}
</div>
<div style="padding-top: 2rem">
${SourcelessTemplate({
${Template({
...args,
position: option,
isOpen: true,
trigger: () => null,
})}
</div>
</div>
Expand Down
36 changes: 0 additions & 36 deletions components/popover/stories/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,39 +171,3 @@ export const Template = ({
</div>
`;
};

export const SourcelessTemplate = ({
rootClass = "spectrum-Popover",
size = "m",
isOpen = false,
withTip = false,
position = "top",
customClasses = [],
id = "popover-1",
testId,
customStyles = {},
content = [],
}) => html`
<div
class=${classMap({
[rootClass]: true,
"is-open": isOpen,
[`${rootClass}--size${size?.toUpperCase()}`]:
typeof size !== "undefined",
[`${rootClass}--withTip`]: withTip,
[`${rootClass}--${position}`]: typeof position !== "undefined",
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
})}
style=${ifDefined(styleMap(customStyles))}
role="presentation"
id=${ifDefined(id)}
data-testid=${ifDefined(testId)}
>
${content.map((c) => (typeof c === "function" ? c({}) : c))}
${withTip
? position && ["top", "bottom"].some((e) => position.startsWith(e))
? html`<svg class="${rootClass}-tip" viewBox="0 -0.5 16 9" width="10"><path class="${rootClass}-tip-triangle" d="M-1,-1 8,8 17,-1"></svg>`
: html`<svg class="${rootClass}-tip" viewBox="0 -0.5 9 16" width="10"><path class="${rootClass}-tip-triangle" d="M-1,-1 8,8 -1,17"></svg>`
: ""}
</div>
`;

0 comments on commit fe34cdf

Please sign in to comment.