Skip to content

Commit

Permalink
Small UI fixes (#2345)
Browse files Browse the repository at this point in the history
* Remove unnecessary coerced Boolean

* Pluralize Namespaces badge for Nexus endpoints

* Fix action slot on Accordion component

* Ignore a11y test on Accordion with action
  • Loading branch information
laurakwhit authored Sep 24, 2024
1 parent 24c74ab commit a9487eb
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 19 deletions.
7 changes: 6 additions & 1 deletion .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import type { TestRunnerConfig } from '@storybook/test-runner';
import { getStoryContext } from '@storybook/test-runner';
import { injectAxe, checkA11y } from 'axe-playwright';

const config: TestRunnerConfig = {
async preVisit(page) {
await injectAxe(page);
},
async postVisit(page) {
async postVisit(page, context) {
const storyContext = await getStoryContext(page, context);
if (storyContext.parameters?.a11y?.disable) {
return;
}
await checkA11y(page, '#storybook-root', {
detailedReport: true,
detailedReportOptions: {
Expand Down
19 changes: 19 additions & 0 deletions src/lib/holocene/accordion/accordion.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import { action } from '@storybook/addon-actions';
import { Story, Template } from '@storybook/addon-svelte-csf';
import Link from '../link.svelte';
import AccordionGroup from './accordion-group.svelte';
</script>

Expand Down Expand Up @@ -63,3 +65,20 @@
<Story name="With Error" args={{ error: 'Error' }} />

<Story name="With Icon" args={{ icon: 'workflow' }} />

<Story
name="With Action"
let:args
parameters={{
a11y: {
disable: true,
},
}}
>
<Accordion {...args} onToggle={action('onToggle')}>
<p>Accordion Content</p>
<Link href="https://docs.temporal.io/" newTab slot="action" icon="book">
<span class="sr-only">docs</span>
</Link>
</Accordion>
</Story>
8 changes: 4 additions & 4 deletions src/lib/holocene/accordion/accordion.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@
role="none"
>
<slot name="action" />
<Icon
class="m-2 shrink-0"
name={open ? 'chevron-up' : 'chevron-down'}
/>
</div>
<Icon
class="m-2 shrink-0"
name={open ? 'chevron-up' : 'chevron-down'}
/>
</div>
<p class="flex items-center">
{#if error}
Expand Down
7 changes: 6 additions & 1 deletion src/lib/pages/nexus-endpoints.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import { timeFormat } from '$lib/stores/time-format';
import type { NexusEndpoint } from '$lib/types/nexus';
import { formatDate } from '$lib/utilities/format-date';
import { pluralize } from '$lib/utilities/pluralize';
import {
routeForNexusEndpoint,
routeForNexusEndpointCreate,
Expand Down Expand Up @@ -90,7 +91,11 @@
{/if}
{#if endpoint.spec?.allowedCallerNamespaces}
<Badge type="primary" class="px-2 py-1"
>{endpoint.spec?.allowedCallerNamespaces.length} Namespaces</Badge
>{endpoint.spec?.allowedCallerNamespaces.length}
{pluralize(
translate('namespaces.namespace'),
endpoint.spec?.allowedCallerNamespaces.length,
)}</Badge
>
{/if}
</div>
Expand Down
24 changes: 11 additions & 13 deletions src/routes/(app)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,54 +69,52 @@
href: workflowsRoute,
icon: 'workflow',
label: translate('common.workflows'),
isActive: (path) => Boolean(path.includes(workflowsRoute)),
isActive: (path) => path.includes(workflowsRoute),
},
{
href: schedulesRoute,
icon: 'schedules',
label: translate('common.schedules'),
isActive: (path) => Boolean(path.includes(schedulesRoute)),
isActive: (path) => path.includes(schedulesRoute),
},
{
href: batchOperationsRoute,
icon: 'batch-operation',
label: translate('batch.nav-title'),
tooltip: translate('batch.list-page-title'),
animate: inProgressBatch,
isActive: (path) => Boolean(path.includes(batchOperationsRoute)),
isActive: (path) => path.includes(batchOperationsRoute),
},
{
href: archivalRoute,
icon: 'archives',
label: translate('common.archive'),
isActive: (path) => Boolean(path.includes(archivalRoute)),
isActive: (path) => path.includes(archivalRoute),
},
{
href: namespacesRoute,
icon: 'namespace',
label: translate('common.namespaces'),
divider: true,
isActive: (path) =>
Boolean(
path.includes(namespacesRoute) &&
!path.includes(workflowsRoute) &&
!path.includes(schedulesRoute) &&
!path.includes(batchOperationsRoute) &&
!path.includes(archivalRoute),
),
path.includes(namespacesRoute) &&
!path.includes(workflowsRoute) &&
!path.includes(schedulesRoute) &&
!path.includes(batchOperationsRoute) &&
!path.includes(archivalRoute),
},
{
href: nexusRoute,
icon: 'nexus',
label: translate('nexus.nexus'),
hidden: !$page.data?.systemInfo?.capabilities?.nexus,
isActive: (path) => Boolean(path.includes(nexusRoute)),
isActive: (path) => path.includes(nexusRoute),
},
{
href: historyImportRoute,
icon: 'import',
label: translate('common.import'),
isActive: (path) => Boolean(path.includes(historyImportRoute)),
isActive: (path) => path.includes(historyImportRoute),
},
{
href: 'http://docs.temporal.io',
Expand Down

0 comments on commit a9487eb

Please sign in to comment.