Skip to content
Closed
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/tidy-load-more-link.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@neovici/cosmoz-queue': patch
---

Render Load more as a centered text link with a focus indicator around the control instead of the full table row.
4 changes: 2 additions & 2 deletions src/list/more/render-more.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '@neovici/cosmoz-button';
import '@neovici/cosmoz-spinner';

Check warning on line 2 in src/list/more/render-more.ts

View workflow job for this annotation

GitHub Actions / build / build

'@neovici/cosmoz-spinner' should be listed in the project's dependencies. Run 'npm i -S @neovici/cosmoz-spinner' to add it
import { t } from 'i18next';
import { html, nothing } from 'lit-html';
import { until } from 'lit-html/directives/until.js';
Expand All @@ -17,10 +17,10 @@
onMore?: () => void;
}) =>
html`<cosmoz-button
variant="primary"
size="lg"
variant="link"
class="more"
slot="extraContent"
style="align-self: center; margin: calc(var(--cz-spacing) * 2);"
?hidden="${!onMore}"
@click="${onMore}"
>
Expand Down
38 changes: 38 additions & 0 deletions stories/load-more.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { Meta, StoryObj } from '@storybook/web-components';
import i18next from 'i18next';
import { html } from 'lit-html';
import { expect, fn, userEvent } from 'storybook/test';
import { renderLoadMore } from '../src/list/more/render-more';

const meta: Meta = {
title: 'List/Load more',
async beforeEach() {
await i18next.init({ lng: 'en', resources: {} });
},
};

export default meta;

export const Link: StoryObj = {
args: { onMore: fn() },
render: ({ onMore }) => html`
<div style="display: flex; flex-direction: column; width: 100%;">
${renderLoadMore({ onMore })}
</div>
`,
async play({ canvasElement, args }) {
const host = canvasElement.querySelector('cosmoz-button')!;
const button = host.shadowRoot!.querySelector('button')!;
const surface = getComputedStyle(button);

expect(surface.backgroundColor).toBe('rgba(0, 0, 0, 0)');
expect(surface.boxShadow).toBe('none');
expect(host.getBoundingClientRect().width).toBeGreaterThan(24);
expect(host.getBoundingClientRect().width).toBeLessThan(
canvasElement.getBoundingClientRect().width / 2,
);

await userEvent.click(button);
expect(args.onMore).toHaveBeenCalledOnce();
},
};
Loading