Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Audit VIconButton sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Oct 26, 2022
1 parent 3da22e9 commit 8b08bf7
Show file tree
Hide file tree
Showing 22 changed files with 100 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/components/VAudioTrack/layouts/VFullLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div
class="items-top mx-auto mt-6 flex flex-row flex-wrap gap-6 px-6 lg:max-w-5xl lg:flex-nowrap"
>
<slot name="play-pause" :size="isSmall ? 'small' : 'medium'" />
<slot name="play-pause" :size="isSmall ? 'small' : 'larger'" />

<div
class="audio-info order-2 flex w-full flex-col justify-center lg:order-1 lg:w-auto"
Expand Down
2 changes: 1 addition & 1 deletion src/components/VAudioTrack/layouts/VGlobalLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="global-track flex w-full flex-row">
<div class="flex-shrink-0">
<VAudioThumbnail :audio="audio" />
<slot name="play-pause" size="medium" layout="global" />
<slot name="play-pause" size="larger" layout="global" />
</div>

<div class="relative flex-grow">
Expand Down
2 changes: 1 addition & 1 deletion src/components/VAudioTrack/layouts/VRowLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
>
<slot
name="play-pause"
:size="isLarge ? 'medium' : 'large'"
:size="isLarge ? 'larger' : 'large'"
:layout="'row'"
:is-tabbable="false"
/>
Expand Down
10 changes: 5 additions & 5 deletions src/components/VAudioTrack/meta/VAudioTrack.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import wavWaveform from './wav-waveform.json'
/>

export const commonAttrs = () => ({
id: Math.floor(Math.random() * 1e9),
id: Math.floor(Math.random() * 1e9).toString(),
creator: 'Wolfgang Amadeus Mozart',
creator_url: 'https://en.wikipedia.org/wiki/Wolfgang_Amadeus_Mozart',
category: 'music',
Expand Down Expand Up @@ -134,7 +134,7 @@ specifying a `layout`. The layout can further be customised by the `size` prop.
size: 's',
}}
parameters={{
viewport: { defaultViewport: 'mob' },
viewport: { defaultViewport: 'sm' },
}}
>
{Template.bind({})}
Expand Down Expand Up @@ -181,7 +181,7 @@ specifying a `layout`. The layout can further be customised by the `size` prop.
size: 's',
}}
parameters={{
viewport: { defaultViewport: 'mob' },
viewport: { defaultViewport: 'sm' },
}}
>
{Template.bind({})}
Expand Down Expand Up @@ -226,7 +226,7 @@ dimension.
size: 's',
}}
parameters={{
viewport: { defaultViewport: 'mob' },
viewport: { defaultViewport: 'sm' },
}}
>
{Template.bind({})}
Expand All @@ -245,7 +245,7 @@ across pages when navigating.
layout: 'global',
}}
parameters={{
viewport: { defaultViewport: 'mob' },
viewport: { defaultViewport: 'sm' },
}}
>
{Template.bind({})}
Expand Down
6 changes: 1 addition & 5 deletions src/components/VContentReport/VContentReportPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
<div class="relative" data-testid="content-report-popover">
<VIconButton
class="absolute top-0 border-none text-dark-charcoal-70 end-0"
size="search-medium"
:icon-props="{ iconPath: icons.closeSmall }"
:button-props="{
'aria-label': $t('modal.close').toString(),
variant: 'plain',
}"
:aria-label="$t('modal.close').toString()"
@click="close"
/>
<VContentReportForm
Expand Down
6 changes: 1 addition & 5 deletions src/components/VExternalSearch/VExternalSourceList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@
>
<VIconButton
class="absolute top-0 border-none text-dark-charcoal-70 end-0"
size="search-medium"
:icon-props="{ iconPath: icons.closeSmall }"
:button-props="{
'aria-label': $t('modal.close').toString(),
variant: 'plain',
}"
:aria-label="$t('modal.close').toString()"
@click="close"
/>
<h2 class="description-bold mb-2 px-4 pt-5 text-start">
Expand Down
1 change: 1 addition & 0 deletions src/components/VGlobalAudioSection/VGlobalAudioSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<VIconButton
v-if="audio"
class="absolute top-0 z-20 border-none ltr:right-0 rtl:left-0"
size="larger"
:icon-props="{ iconPath: icons.closeIcon }"
@click="handleClose"
/>
Expand Down
4 changes: 0 additions & 4 deletions src/components/VHeader/VHeaderInternal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
<VIconButton
ref="menuButtonRef"
:icon-props="{ iconPath: menuIcon }"
:button-props="{ variant: 'plain' }"
:aria-label="$t('header.aria.menu')"
v-bind="a11yProps"
class="border-tx hover:bg-dark-charcoal hover:text-white"
size="search-medium"
/>
</template>

Expand All @@ -34,9 +32,7 @@
<VHomeLink variant="light" />
<VIconButton
ref="closeButton"
:button-props="{ variant: 'plain' }"
:icon-props="{ iconPath: closeIcon }"
size="search-medium"
class="border-tx text-white focus-visible:ring-offset-tx"
:aria-label="$t('modal.close')"
@click="closeModal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
}}</VTab>
<VIconButton
class="self-center ms-auto hover:bg-dark-charcoal hover:text-white"
size="search-medium"
:icon-props="{ iconPath: closeIcon }"
:aria-label="$t('modal.aria-close')"
@click="closeModal"
Expand Down
1 change: 0 additions & 1 deletion src/components/VHeader/VHeaderMobile/VSearchBarButton.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<VIconButton
size="search-medium"
class="border-tx bg-tx"
:button-props="{ variant: 'plain--avoid' }"
v-on="$listeners"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ If any filters are selected, it shows a pink dot in the top right corner.
## Clear button and Back button

export const activeButtonsTemplate = (args) => ({
template: `<div class="rounded-sm bg-white flex justify-between ring ring-pink">
template: `<div class="wrapper rounded-sm bg-white flex justify-between ring ring-pink">
<VSearchBarButton
:icon-path="chevronLeftIcon"
:inner-size="8"
Expand Down
10 changes: 2 additions & 8 deletions src/components/VIconButton/VIconButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@ import VButton, { type ButtonProps } from '~/components/VButton.vue'
const SIZE_MAP = Object.freeze({
tiny: { icon: 6, button: 'w-6 h-6' },
small: { icon: 6, button: 'w-10 h-10' },
smaller: { icon: 6, button: 'w-8 h-8' },
// TODO: audit the sizes after new header is done.
'new-small': { icon: 4, button: 'w-8 h-8' },
'search-small': { icon: 6, button: '!w-10 md:w-12 !h-10 md:h-12' },
'search-medium': { icon: 6, button: 'w-12 h-12' },
'search-large': { icon: 6, button: 'w-14 h-14' },
'search-standalone': { icon: 6, button: 'w-14 md:w-[69px] h-14 md:h-[69px]' },
medium: { icon: 8, button: 'w-14 h-14' },
medium: { icon: 6, button: 'w-12 h-12' },
larger: { icon: 8, button: 'w-14 h-14' },
large: { icon: 12, button: 'w-20 h-20' },
} as const)
type Size = keyof typeof SIZE_MAP
Expand Down
34 changes: 33 additions & 1 deletion src/components/VIconButton/meta/VIconButton.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import replayIcon from '~/assets/icons/replay.svg'
argTypes={{
size: {
defaultValue: 'medium',
options: ['tiny', 'small', 'search', 'medium', 'large'],
options: ['tiny', 'small', 'medium', 'larger', 'large'],
control: 'select',
},
}}
Expand All @@ -32,6 +32,23 @@ export const Template = (args) => ({
},
})

export const sizesTemplate = (args) => ({
template: `
<div class="flex gap-x-2">
<div v-for="size in ['tiny', 'small', 'medium', 'larger', 'large']" :key="size" class="flex flex-col items-center p-2">
<p>{{ size }}</p>
<VIconButton
class="text-white bg-dark-charcoal border-dark-charcoal"
:size="size" v-bind="args" />
</div>
</div>
`,
components: { VIconButton },
setup() {
return { args }
},
})

# Icon Button

<Description of={VIconButton} />
Expand All @@ -50,3 +67,18 @@ export const Template = (args) => ({
{Template.bind({})}
</Story>
</Canvas>

## Sizes

<Canvas>
<Story
name="Sizes"
args={{
iconProps: {
iconPath: replayIcon,
},
}}
>
{sizesTemplate.bind({})}
</Story>
</Canvas>
2 changes: 0 additions & 2 deletions src/components/VNotificationBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
<slot name="buttons">
<VIconButton
:class="variant === 'announcement' && 'text-white'"
class="border-none"
:button-props="{ variant: 'plain' }"
size="small"
:aria-label="closeLabel"
:icon-props="{
Expand Down
12 changes: 12 additions & 0 deletions test/storybook/visual-regression/v-icon-button.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect, test } from '@playwright/test'

test.describe('VIconButton', () => {
const url = '/iframe.html?id=components-viconbutton--sizes'

test('icon button sizes', async ({ page }) => {
await page.goto(url)
expect(await page.screenshot()).toMatchSnapshot({
name: 'v-icon-button-sizes.png',
})
})
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions test/storybook/visual-regression/v-search-bar-button.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { expect, test } from '@playwright/test'

test.describe.configure({ mode: 'parallel' })
const wrapperLocator = '.wrapper'
test.describe('VSearchBarButton', () => {
test.beforeEach(async ({ page }) => {
await page.goto(
'/iframe.html?id=components-vheader-vheadermobile-vsearchbarbutton--clear-and-back-buttons'
)
})
test('Clear and back buttons resting', async ({ page }) => {
expect(await page.locator(wrapperLocator).screenshot()).toMatchSnapshot({
name: `clear-back-buttons-resting.png`,
})
})

test(`Back button hovered`, async ({ page }) => {
await page.hover('.wrapper>button:nth-child(1)')
expect(await page.locator(wrapperLocator).screenshot()).toMatchSnapshot({
name: `back-button-hovered.png`,
})
})
test(`Back button focused`, async ({ page }) => {
await page.focus('.wrapper>button:nth-child(1)')
expect(await page.locator(wrapperLocator).screenshot()).toMatchSnapshot({
name: `back-button-focused.png`,
})
})
test(`Clear button hovered`, async ({ page }) => {
await page.hover('.wrapper>button:nth-child(2)')
expect(await page.locator(wrapperLocator).screenshot()).toMatchSnapshot({
name: `clear-button-hovered.png`,
})
})
test(`Clear button focused`, async ({ page }) => {
await page.hover('.wrapper>button:nth-child(2)')
expect(await page.locator(wrapperLocator).screenshot()).toMatchSnapshot({
name: `clear-button-focused.png`,
})
})
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8b08bf7

Please sign in to comment.