Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/witty-hats-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@stackoverflow/stacks-svelte": patch
---

vote component: allow downvoting for horizontal layout
50 changes: 2 additions & 48 deletions packages/stacks-classic/lib/components/vote/vote.a11y.test.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,12 @@
import { runA11yTests } from "../../test/a11y-test-utils";
import {
IconVote16Up,
IconVote16Down,
} from "@stackoverflow/stacks-icons/icons";
import { children } from "./vote.test.setup";
import "../../index";

const children = {
default: `
<button class="s-vote--btn">
${IconVote16Up}
<span class="v-visible-sr">upvote</span>
</button>
<span class="s-vote--votes">
<span class="s-vote--total">12</span>
<span class="s-vote--upvotes">+20</span>
<span class="s-vote--downvotes">-8</span>
</span>
<button class="s-vote--btn">
${IconVote16Down}
<span class="v-visible-sr">downvote</span>
</button>
`,
upvoteOnly: `
<button class="s-vote--btn">
${IconVote16Up}
<span class="v-visible-sr">upvote</span>
</button>
<span class="s-vote--votes">
<span class="s-vote--total">12</span>
<span class="s-vote--upvotes">+20</span>
<span class="s-vote--downvotes">-8</span>
</span>
`,
};

describe("vote", () => {
runA11yTests({
baseClass: "s-vote",
modifiers: {
primary: ["expanded"],
},
children: {
default: children.default,
},
});

// Horizontal with and without downvote
runA11yTests({
baseClass: "s-vote",
modifiers: {
primary: ["horizontal"],
},
options: {
includeNullModifier: false,
primary: ["expanded", "horizontal"],
},
children,
});
Expand Down
35 changes: 35 additions & 0 deletions packages/stacks-classic/lib/components/vote/vote.test.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
IconVote16Up,
IconVote16Down,
} from "@stackoverflow/stacks-icons/icons";

const children = {
default: `
<button class="s-vote--btn">
${IconVote16Up}
<span class="v-visible-sr">upvote</span>
</button>
<span class="s-vote--votes">
<span class="s-vote--total">12</span>
<span class="s-vote--upvotes">+20</span>
<span class="s-vote--downvotes">-8</span>
</span>
<button class="s-vote--btn">
${IconVote16Down}
<span class="v-visible-sr">downvote</span>
</button>
`,
upvoteOnly: `
<button class="s-vote--btn">
${IconVote16Up}
<span class="v-visible-sr">upvote</span>
<span class="s-vote--votes">
<span class="s-vote--total">12</span>
<span class="s-vote--upvotes">+20</span>
<span class="s-vote--downvotes">-8</span>
</span>
</button>
`,
};

export { children };
55 changes: 3 additions & 52 deletions packages/stacks-classic/lib/components/vote/vote.visual.test.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,15 @@
import { runVisualTests } from "../../test/visual-test-utils";
import { html } from "@open-wc/testing";
import {
IconVote16Up,
IconVote16Down,
} from "@stackoverflow/stacks-icons/icons";
import { children } from "./vote.test.setup";
import "../../index";

describe("vote", () => {
runVisualTests({
baseClass: "s-vote",
modifiers: {
primary: ["expanded"],
},
children: {
default: `
<button class="s-vote--btn">
${IconVote16Up}
<span class="v-visible-sr">upvote</span>
</button>
<span class="s-vote--votes">
<span class="s-vote--total">12</span>
<span class="s-vote--upvotes">+20</span>
<span class="s-vote--downvotes">-8</span>
</span>
<button class="s-vote--btn">
${IconVote16Down}
<span class="v-visible-sr">downvote</span>
</button>
`,
},
template: ({ component, testid }) => html`
<div
class="d-inline-flex ai-center jc-center ws1 p8"
data-testid="${testid}"
>
${component}
</div>
`,
});

// Horizontal with and without downvote
runVisualTests({
baseClass: "s-vote",
modifiers: {
primary: ["horizontal"],
},
options: {
includeNullModifier: false,
},
children: {
default: `
<button class="s-vote--btn">
${IconVote16Up}
<span class="v-visible-sr">upvote</span>
<span class="s-vote--votes">
<span class="s-vote--upvotes">+20</span>
</span>
</button>
`,
primary: ["expanded", "horizontal"],
},
children,
template: ({ component, testid }) => html`
<div
class="d-inline-flex ai-center jc-center ws1 p8"
Expand Down
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Loading