Skip to content

Commit

Permalink
feat(tags): add tags pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook committed May 7, 2020
1 parent 4c71eb1 commit ae91865
Show file tree
Hide file tree
Showing 22 changed files with 1,771 additions and 1,709 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@
"@commitlint/cli": "^8.3.4",
"@commitlint/config-conventional": "^8.3.4",
"@commitlint/config-lerna-scopes": "^8.3.4",
"@open-wc/building-webpack": "^2.13.12",
"@open-wc/demoing-storybook": "^2.0.2",
"@open-wc/building-webpack": "^2.13.16",
"@open-wc/demoing-storybook": "^2.1.3",
"@open-wc/polyfills-loader": "^0.3.3",
"@open-wc/testing": "^2.5.11",
"@open-wc/testing-karma": "^3.3.12",
"@open-wc/testing": "^2.5.16",
"@open-wc/testing-karma": "^3.3.17",
"@spectrum-css/rule": "^2.0.6",
"@spectrum-css/table": "^2.0.6",
"@types/chai": "^4.1.7",
Expand Down
1 change: 1 addition & 0 deletions packages/bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@spectrum-web-components/switch": "^0.2.14",
"@spectrum-web-components/tab": "^0.3.8",
"@spectrum-web-components/tab-list": "^0.3.9",
"@spectrum-web-components/tags": "^0.0.1",
"@spectrum-web-components/textfield": "^0.3.7",
"@spectrum-web-components/theme": "^0.4.0",
"@spectrum-web-components/toast": "^0.3.1",
Expand Down
1 change: 1 addition & 0 deletions packages/bundle/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export * from '@spectrum-web-components/status-light';
export * from '@spectrum-web-components/switch';
export * from '@spectrum-web-components/tab';
export * from '@spectrum-web-components/tab-list';
export * from '@spectrum-web-components/tags';
export * from '@spectrum-web-components/textfield';
export * from '@spectrum-web-components/theme';
export * from '@spectrum-web-components/toast';
Expand Down
1 change: 1 addition & 0 deletions packages/bundle/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
{ "path": "../switch" },
{ "path": "../tab" },
{ "path": "../tab-list" },
{ "path": "../tags" },
{ "path": "../textfield" },
{ "path": "../theme" },
{ "path": "../toast" },
Expand Down
136 changes: 136 additions & 0 deletions packages/tags/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
## Description

`sp-tags` and `sp-tag` elements allow users to categorize content. They can represent keywords or people, and are grouped to describe an item or a search request.

## To do:

Keyboard interactions

### Installation

[![See it on NPM!](https://img.shields.io/npm/v/@spectrum-web-components/tags?style=for-the-badge)](https://www.npmjs.com/package/@spectrum-web-components/tags)
[![How big is this package in your project?](https://img.shields.io/bundlephobia/minzip/@spectrum-web-components/tags?style=for-the-badge)](https://bundlephobia.com/result?p=@spectrum-web-components/tags)

```
npm install @spectrum-web-components/tags
# or
yarn add @spectrum-web-components/tags
```

## Example

<sp-icons-medium></sp-icons-medium>

```html-live
<sp-tags>
<sp-tag>Tag 1</sp-tag>
<sp-tag invalid>Tag 2</sp-tag>
<sp-tag disabled>Tag 3</sp-tag>
</sp-tags>
```

```html-live
<sp-tags>
<sp-tag>
Tag 1
<sp-avatar
slot="avatar"
label="Tag 1"
src=https://placedog.net/500/500
></sp-avatar>
</sp-tag>
<sp-tag invalid>
Tag 2
<sp-avatar
slot="avatar"
label="Tag 1"
src=https://placedog.net/500/500
></sp-avatar>
</sp-tag>
<sp-tag disabled>
Tag 3
<sp-avatar
slot="avatar"
label="Tag 1"
src=https://placedog.net/500/500
></sp-avatar>
</sp-tag>
</sp-tags>
```

```html-live
<sp-tags>
<sp-tag>
Tag 1
<sp-icon slot="icon" size="xs" name="ui:Magnifier"></sp-icon>
</sp-tag>
<sp-tag invalid>
Tag 2
<sp-icon slot="icon" size="xs" name="ui:Magnifier"></sp-icon>
</sp-tag>
<sp-tag disabled>
Tag 3
<sp-icon slot="icon" size="xs" name="ui:Magnifier"></sp-icon>
</sp-tag>
</sp-tags>
```

### Deletable

Use the `deletable` attribute to signify `sp-tags` elements that can be removed.

```html-live
<sp-tags>
<sp-tag deletable>Tag 1</sp-tag>
<sp-tag invalid deletable>Tag 2</sp-tag>
<sp-tag disabled deletable>Tag 3</sp-tag>
</sp-tags>
```

```html-live
<sp-tags>
<sp-tag deletable>
Tag 1
<sp-avatar
slot="avatar"
label="Tag 1"
src=https://placedog.net/500/500
></sp-avatar>
</sp-tag>
<sp-tag invalid deletable>
Tag 2
<sp-avatar
slot="avatar"
label="Tag 1"
src=https://placedog.net/500/500
></sp-avatar>
</sp-tag>
<sp-tag disabled deletable>
Tag 3
<sp-avatar
slot="avatar"
label="Tag 1"
src=https://placedog.net/500/500
></sp-avatar>
</sp-tag>
</sp-tags>
```

```html-live
<sp-tags>
<sp-tag deletable>
Tag 1
<sp-icon slot="icon" size="xs" name="ui:Magnifier"></sp-icon>
</sp-tag>
<sp-tag invalid deletable>
Tag 2
<sp-icon slot="icon" size="xs" name="ui:Magnifier"></sp-icon>
</sp-tag>
<sp-tag disabled deletable>
Tag 3
<sp-icon slot="icon" size="xs" name="ui:Magnifier"></sp-icon>
</sp-tag>
</sp-tags>
```
48 changes: 48 additions & 0 deletions packages/tags/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "@spectrum-web-components/tags",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/adobe/spectrum-web-components.git",
"directory": "packages/tags"
},
"bugs": {
"url": "https://github.com/adobe/spectrum-web-components/issues"
},
"homepage": "https://adobe.github.io/spectrum-web-components/components/tags",
"keywords": [
"spectrum css",
"web components",
"lit-element",
"lit-html"
],
"version": "0.0.1",
"description": "",
"main": "lib/index.js",
"module": "lib/index.js",
"type": "module",
"files": [
"custom-elements.json",
"/lib/",
"/src/"
],
"scripts": {
"test": "karma start --coverage"
},
"author": "",
"license": "Apache-2.0",
"peerDependencies": {
"lit-element": "^2.1.0",
"lit-html": "^1.0.0"
},
"devDependencies": {
"@spectrum-css/tags": "^2.0.0"
},
"dependencies": {
"@spectrum-web-components/button": "^0.5.1",
"@spectrum-web-components/shared": "^0.4.6",
"tslib": "^1.10.0"
}
}
33 changes: 33 additions & 0 deletions packages/tags/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2020 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

export * from './tags.js';
export * from './tag.js';

import { Tags } from './tags.js';
import { Tag } from './tag.js';

/* istanbul ignore else */
if (!customElements.get('sp-tags')) {
customElements.define('sp-tags', Tags);
}
/* istanbul ignore else */
if (!customElements.get('sp-tag')) {
customElements.define('sp-tag', Tag);
}

declare global {
interface HTMLElementTagNameMap {
'sp-tags': Tags;
'sp-tag': Tag;
}
}
71 changes: 71 additions & 0 deletions packages/tags/src/spectrum-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
Copyright 2020 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

module.exports = {
spectrum: 'tags',
components: [
{
name: 'tags',
host: {
selector: '.spectrum-Tags',
},
exclude: [/\.spectrum-Tags-item/],
},
{
name: 'tag',
host: {
selector: '.spectrum-Tags-item',
},
attributes: [
{
selector: '.is-disabled',
type: 'boolean',
name: 'disabled',
},
{
selector: '.is-invalid',
type: 'boolean',
name: 'invalid',
},
{
selector: '.spectrum-Tags-item--deletable',
type: 'boolean',
name: 'deletable',
},
],
classes: [
{
selector: '.spectrum-ClearButton',
name: 'clear-button',
},
{
selector: '.spectrum-Tags-itemLabel',
name: 'label',
},
],
slots: [
{
selector: '.spectrum-Avatar',
name: 'avatar',
},
{
selector: '.spectrum-Icon',
name: 'icon',
},
],
exclude: [
/\.spectrum-Tags /,
/\.spectrum-ClearButton \.spectrum-Icon/,
],
},
],
};
Loading

0 comments on commit ae91865

Please sign in to comment.