Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(filter-pill): DLT-1917 create component #473

Open
wants to merge 30 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
94b3ef3
setup component
juliodialpad Aug 20, 2024
6a0e8a4
move styles to dialtone-css
juliodialpad Aug 21, 2024
6c60b1c
add loading state
juliodialpad Aug 21, 2024
e115b65
Merge branch 'staging' into feat/filter-pill-component-vue
juliodialpad Aug 21, 2024
3ee1ecb
cleanup
juliodialpad Aug 21, 2024
2712981
add headerContent and footerContent slots
juliodialpad Aug 21, 2024
b11b1cd
add examples
juliodialpad Aug 21, 2024
c435a93
update docs
juliodialpad Aug 21, 2024
22c4e87
add tests
juliodialpad Aug 21, 2024
71ccf1f
Vue 3 migration
juliodialpad Aug 23, 2024
fb85a47
cleanup
juliodialpad Aug 23, 2024
a4757e2
add docs
juliodialpad Aug 26, 2024
fa2b736
add to site-nav
juliodialpad Aug 26, 2024
62d3c73
Merge branch 'refs/heads/staging' into feat/filter-pill-component-vue
juliodialpad Aug 26, 2024
1725596
sync
juliodialpad Aug 26, 2024
37f3353
test commit
juliodialpad Aug 26, 2024
3135d58
update lint-staged config
juliodialpad Aug 26, 2024
7b07aef
update lint-staged to include .eslintignore
juliodialpad Aug 26, 2024
62b4fce
test commit
juliodialpad Aug 26, 2024
2a738e4
add resetButtonAriaLabel
juliodialpad Aug 26, 2024
45e8d59
add size prop
juliodialpad Aug 27, 2024
08bc083
add size prop - vue 3
juliodialpad Aug 27, 2024
f5ba936
update docs
juliodialpad Aug 27, 2024
758c78c
update example
juliodialpad Aug 27, 2024
1e43cf6
add aria-label on loading only
juliodialpad Aug 27, 2024
196b9a9
Merge branch 'staging' into feat/filter-pill-component-vue
juliodialpad Aug 27, 2024
42c9778
Merge branch 'staging' into feat/filter-pill-component-vue
juliodialpad Sep 2, 2024
68534ba
update tokens
juliodialpad Sep 2, 2024
e47a20b
use v-model
juliodialpad Sep 2, 2024
7c01c19
add pass-through props
juliodialpad Sep 2, 2024
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
19 changes: 19 additions & 0 deletions apps/dialtone-documentation/docs/_data/filter-pill.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"classes": [
{
"class": "d-filter-pill",
"applies": "N/A",
"description": "Base filter pill style."
},
{
"class": "d-filter-pill__wrapper",
"applies": "N/A",
"description": "Applies relative positioning."
},
{
"class": "d-filter-pill__icon",
"applies": "N/A",
"description": "Applies the icon color."
}
]
}
5 changes: 5 additions & 0 deletions apps/dialtone-documentation/docs/_data/site-nav.json
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,11 @@
"text": "Empty State",
"link": "/components/empty-state.html"
},
{
"text": "Filter Pill",
"link": "/components/filter-pill.html",
"planned": true
},
{
"text": "Hovercard",
"link": "/components/hovercard.html"
Expand Down
241 changes: 241 additions & 0 deletions apps/dialtone-documentation/docs/components/filter-pill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
---
title: Filter Pill
description: A Filter Pill offers a button paired with a popover to show and manage filtering options, the label and state of the filter can be handled through events and props.
status: beta
# storybook: https://dialtone.dialpad.com/vue/?path=/story/components-filter-pill--default @TODO: Uncomment once it's RFP
---

<code-well-header>
<dt-filter-pill
label="With header, content and footer"
>
<template #headerContent>
<div class="d-mr16">
<dt-input
v-model="inputValue"
aria-label="Search items"
placeholder="Search Items"
type="text"
>
<template #leftIcon="{ iconSize }">
<dt-icon-search
:size="iconSize"
/>
</template>
<template
#rightIcon="{ clear }"
>
<dt-button
kind="muted"
importance="clear"
size="xs"
circle
aria-label="Clear search"
@click="clear"
>
<template #icon="{ iconSize }">
<dt-icon-close
:size="iconSize"
/>
</template>
</dt-button>
</template>
</dt-input>
</div>
</template>
<template #content>
<dt-checkbox
v-for="option in options"
:key="option"
:label="option"
/>
</template>
<template #footerContent>
<div class="d-ta-right d-pr16">
<dt-button
kind="muted"
importance="outlined"
size="sm"
>
Apply
</dt-button>
</div>
</template>
</dt-filter-pill>
</code-well-header>

## Variants

### Base

<code-well-header>
<dt-stack direction="row" gap="400">
<dt-filter-pill
label="Simple example"
ref="simpleExample"
>
<template #content>
Main content
</template>
</dt-filter-pill>
</dt-stack>
</code-well-header>

<code-example-tabs
:htmlCode='() => $refs.simpleExample'
vueCode='
<dt-filter-pill label="Simple example">
<template #content>
Main content
</template>
</dt-filter-pill>
'
showHtmlWarning />

### Disabled

<code-well-header>
<dt-stack direction="row" gap="400">
<dt-filter-pill label="Disabled filter" disabled ref="disabledFilter"></dt-filter-pill>
</dt-stack>
</code-well-header>

<code-example-tabs
:htmlCode='() => $refs.disabledFilter'
vueCode='<dt-filter-pill label="Disabled filter" disabled/>'
showHtmlWarning />

### Active

<code-well-header>
<dt-stack direction="row" gap="400">
<dt-filter-pill
label="Active example"
active
ref="activeExample"
>
<template #content>
Main content
</template>
</dt-filter-pill>
</dt-stack>
</code-well-header>

<code-example-tabs
:htmlCode='() => $refs.activeExample'
vueCode='
<dt-filter-pill label="Active example" active>
<template #content>
Main content
</template>
</dt-filter-pill>
'
showHtmlWarning />

### Loading

When `loading` prop is set, a loading skeleton will be shown, skeleton width can
be customized via `loading-skeleton-width` prop.

<code-well-header>
<dt-stack direction="row" gap="400">
<dt-filter-pill
label="Loading example"
loading
ref="loadingExample"
>
<template #content>
Loading filter
</template>
</dt-filter-pill>
<dt-filter-pill
label="Loading example"
loading
loading-skeleton-width="50px"
>
<template #content>
Loading filter with custom width
</template>
</dt-filter-pill>
</dt-stack>
</code-well-header>

<code-example-tabs
:htmlCode='() => $refs.loadingExample'
vueCode='
<dt-filter-pill
label="Loading example"
loading
>
<template #content>
Main content
</template>
</dt-filter-pill>
<dt-filter-pill
label="Loading example"
loading
loading-skeleton-width="50px"
>
<template #content>
Main content
</template>
</dt-filter-pill>
'
showHtmlWarning />

### Clearable

Setting the `show-reset` prop will show a reset button that will emit
the `reset` event when clicked, so you can handle the filter resetting.

<code-well-header>
<dt-stack direction="row" gap="400">
<dt-filter-pill
label="Clearable example"
active
show-reset
ref="clearableExample"
>
<template #content>
Clearable filter
</template>
</dt-filter-pill>
</dt-stack>
</code-well-header>

<code-example-tabs
:htmlCode='() => $refs.clearableExample'
vueCode='
<dt-filter-pill
label="Clearable example"
active
show-reset
>
<template #content>
Main content
</template>
</dt-filter-pill>
'
showHtmlWarning />

## Vue API

<component-vue-api component-name="filterPill"></component-vue-api>

## Classes

<component-class-table component-name="filter-pill"></component-class-table>

<script setup>
import { ref } from 'vue';
import { DtIconSearch, DtIconClose } from '@dialpad/dialtone-icons/vue3';

const inputValue = ref('');
const options = [
'Option 1',
'Option 2',
'Option 3',
'Option 4',
'Option 5',
];
</script>
1 change: 1 addition & 0 deletions common/components_list.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = [
'emoji.vue',
'emoji_picker.vue',
'emoji_text_wrapper.vue',
'filter_pill.vue',
'hovercard.vue',
'icon.vue',
'image_viewer.vue',
Expand Down
28 changes: 22 additions & 6 deletions lint-staged.config.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
const { ESLint } = require('eslint');

const removeIgnoredFiles = async (files) => {
const eslint = new ESLint();
const isIgnored = await Promise.all(
files.map((file) => {
return eslint.isPathIgnored(file);
}),
);
const filteredFiles = files.filter((_, i) => !isIgnored[i]);
return filteredFiles.join(' ');
};
braddialpad marked this conversation as resolved.
Show resolved Hide resolved

module.exports = {
'*.{js, mjs, cjs, vue}': [
'pnpm exec eslint --fix',
],
'**/*.{js, mjs, cjs, vue}': async (files) => {
const filesToLint = await removeIgnoredFiles(files);
return [
`pnpm exec eslint --fix --max-warnings=0 ${filesToLint}`,
];
},
'*.less': [
'pnpm exec stylelint --fix'
'pnpm exec stylelint --fix',
],
'*.{md, mdx}': [
'pnpm exec markdownlint'
]
'pnpm exec markdownlint',
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// DIALTONE
// COMPONENTS: FILTER PILL
//
// These are the styles for filter-pill component.
//
//
// TABLE OF CONTENTS
// โ€ข BASE STYLE

// @@ BASE STYLE
// ----------------------------------------------------------------------------
.d-filter-pill {
&__wrapper {
position: relative;
display: inline-block;

&:has(.d-filter-pill__reset) .d-filter-pill__icon {
visibility: hidden;
}

&:hover .d-filter-pill--active,
&:focus-visible .d-filter-pill--active {
background-color: var(--dt-action-color-background-base-active);
}
}

&__icon {
color: var(--dt-color-foreground-muted);
}

&__reset {
position: absolute;
top: 50%;
juliodialpad marked this conversation as resolved.
Show resolved Hide resolved
right: var(--dt-space-200);
color: var(--dt-color-foreground-primary);
transform: translateY(-50%);
opacity: .5;
juliodialpad marked this conversation as resolved.
Show resolved Hide resolved

&:hover, &:focus-visible {
opacity: 1;
juliodialpad marked this conversation as resolved.
Show resolved Hide resolved
}
}

&--active {
background-color: var(--dt-action-color-background-base-hover);
border: 1px solid var(--dt-action-color-border-base-outlined-default);
juliodialpad marked this conversation as resolved.
Show resolved Hide resolved

&:hover, &:focus-visible {
background-color: var(--dt-action-color-background-base-active);
}
}
}
1 change: 1 addition & 0 deletions packages/dialtone-css/lib/build/less/dialtone.less
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
@import 'components/presence';
@import 'components/icon';
@import 'components/scrollbar';
@import 'components/filter-pill';

// -- UTILITIES
@import 'utilities/backgrounds';
Expand Down
4 changes: 4 additions & 0 deletions packages/dialtone-vue2/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const config = {
stories: [
'../@(components|directives|recipes|prototypes)/**/*.stories.@(js|jsx|ts|tsx)',
'../@(components|directives|docs|functions|recipes)/**/*.mdx',

// @TODO: Replace lines before merging to exclude filter_pill component from storybook.
//'../@(components|directives|recipes|prototypes)/**/!(filter_pill)/*.stories.@(js|jsx|ts|tsx)',
//'../@(components|directives|docs|functions|recipes)/**/!(filter_pill)/*.mdx',
],
addons: ["@storybook/addon-links", "@storybook/addon-essentials", "@storybook/addon-a11y", 'storybook-dark-mode'],
framework: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Meta } from '@storybook/blocks';
import * as DtFilterPillStories from './filter_pill.stories.js';
import RedirectToDocs from "@/common/snippets/redirect-to-docs.mdx"

<Meta of={DtFilterPillStories} />

# Filter Pill

<RedirectToDocs name="filter-pill" />
Loading
Loading