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

Update tag.mdx #4079

Merged
merged 26 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ac21c66
Update tag.mdx
vavalos5 Aug 2, 2024
1be90f9
make changes to align with figma file
britt6612 Sep 17, 2024
0a0ad56
merge with master
britt6612 Sep 17, 2024
fc01542
merge with master
britt6612 Sep 17, 2024
56b256d
address Vicky comments
britt6612 Sep 23, 2024
655c84c
address Vicky comments
britt6612 Sep 23, 2024
f5899d8
Merge branch 'master' of github.com:grommet/hpe-design-system into va…
britt6612 Sep 26, 2024
b931acd
Update aries-site/src/pages/components/tag.mdx
britt6612 Sep 26, 2024
b7a328d
Update aries-site/src/pages/components/tag.mdx
britt6612 Sep 26, 2024
b7ec396
Update aries-site/src/pages/components/tag.mdx
britt6612 Sep 26, 2024
488a7b5
Update aries-site/src/pages/components/tag.mdx
britt6612 Sep 26, 2024
822744c
Update aries-site/src/pages/components/tag.mdx
britt6612 Sep 26, 2024
7e60012
Update aries-site/src/pages/components/tag.mdx
britt6612 Sep 26, 2024
3471583
Update aries-site/src/pages/components/tag.mdx
britt6612 Sep 26, 2024
e7191cc
Update aries-site/src/pages/components/tag.mdx
britt6612 Sep 26, 2024
fb5c7b8
add example in line
britt6612 Sep 27, 2024
7c7ce0d
add example in line
britt6612 Sep 27, 2024
68de13d
Merge branch 'master' of github.com:grommet/hpe-design-system into va…
britt6612 Sep 30, 2024
cce7ae1
change blue color for hightlight tag
britt6612 Oct 2, 2024
76427d3
Merge branch 'master' of github.com:grommet/hpe-design-system into va…
britt6612 Oct 2, 2024
bfe93e7
update yarn
britt6612 Oct 2, 2024
d0fb80d
change blue
britt6612 Oct 2, 2024
4fbfe7b
take out type
britt6612 Oct 2, 2024
ae045d8
Lint fixes and adjust example
taysea Oct 2, 2024
fb85bee
Move example below guidance
taysea Oct 2, 2024
5ae4b14
Merge pull request #4230 from grommet/taylor-tag-feedbac
taysea Oct 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
4 changes: 2 additions & 2 deletions aries-site/src/examples/components/tag/TagAnatomy.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const TagAnatomy = () => {
<Box />
<Annotation id="border-annotation" target="1" />
<Box />
<Annotation alignSelf="center" id="name-annotation" target="3" />
<Annotation alignSelf="center" id="name-annotation" target="2" />
<AnatomyBox
id="border"
nameId="tagName-2"
Expand All @@ -126,7 +126,7 @@ export const TagAnatomy = () => {
}px`,
}}
>
<Annotation id="value-annotation" target="2" />
<Annotation id="value-annotation" target="3" />
</Box>
<Box />
</AnatomyGrid>
Expand Down
26 changes: 26 additions & 0 deletions aries-site/src/examples/components/tag/TagAttention.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { Box, Tag } from 'grommet';
import { Card } from '../../templates';

export const TagAttention = () => {
return (
<Box gap="medium">
<Card
icon={
<Tag
border={{ color: 'blue' }}
value="New"
margin={{ bottom: 'xsmall' }}
/>
}
title="Compute Ops Management"
subtitle="Compute"
description={`Securely manage your compute infrastructure
wherever it is lives.`}
alignActions="end"
onClick={() => {}}
level={3}
/>
</Box>
);
};
65 changes: 65 additions & 0 deletions aries-site/src/examples/components/tag/TagMetaData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React, { useContext } from 'react';
import { Box, Heading, Grid, ResponsiveContext, Tag } from 'grommet';
import { User } from 'grommet-icons';
import { Card } from '../../templates';

const products = [
{
tags: ['USA', 'Colorado', 'HR', 'Full-time'],
},
{
tags: [
{ name: 'Country', value: 'USA' },
{ name: 'Location', value: 'Colorado' },
{ name: 'Department', value: 'HR' },
{ name: 'Type', value: 'Full-time' },
],
},
];
const columns = {
xsmall: ['auto'],
small: ['auto'],
medium: ['auto'],
large: ['auto', 'auto'],
xlarge: ['auto', 'auto'],
};

export const TagMetaData = () => {
const breakpoint = useContext(ResponsiveContext);

return (
<Box gap="medium">
<Heading level={2} margin="none">
My Products
</Heading>
<Grid columns={columns[breakpoint]} gap="medium">
{products.map((product, index) => (
<Card
key={index}
icon={<User />}
title="Program Advisor"
subtitle="June 25, 2024"
description={`Manages the end to end
recruitment process including consulting with HR
and business partners.`}
actions={
<Box direction="row" gap="xsmall" wrap>
{product.tags?.map((tag, j) => (
<Tag
name={tag.name ? tag.name : undefined}
value={tag.value ? tag.value : tag}
key={j}
margin={{ bottom: 'xsmall' }}
/>
))}
</Box>
}
alignActions="end"
onClick={() => {}}
level={3}
/>
))}
</Grid>
</Box>
);
};
4 changes: 4 additions & 0 deletions aries-site/src/examples/components/tag/TagSimple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from 'react';
import { Tag } from 'grommet';

export const TagSimple = () => <Tag name="Location" value="San Jose" />;
3 changes: 3 additions & 0 deletions aries-site/src/examples/components/tag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ export * from './CreateTagSimple';
export * from './data';
export * from './TagBasicAnatomy';
export * from './TagAnatomy';
export * from './TagAttention';
export * from './TagSimple';
export * from './TagResource';
export * from './TagMetaData';
199 changes: 96 additions & 103 deletions aries-site/src/pages/components/tag.mdx
Original file line number Diff line number Diff line change
@@ -1,144 +1,137 @@
import { Example } from '../../layouts';
import {
CreateTag,
CreateTagSimple,
TagAnatomy,
TagBasicAnatomy,
TagAttention,
TagMetaData,
TagSimple,
CreateTagSimple,
TagResource,
} from '../../examples';
import { Example } from '../../layouts';
import { Tag } from 'grommet';

## Guidance

Tags are simple attributes containing metadata. Tags:

- Are simple, brief and concise metadata describing a resource or content.
- Organize and group resources by common characteristics or attributes.
- May be included as an attribute in search, filter, or details of a resource.
- Assist batch actions and selection of multiple resources.

## Anatomy

The most basic tags consist of two primary elements:

<Example caption="Diagram illustrating the primary elements of a tag." plain>
<TagBasicAnatomy />
<Example
componentName="Tag"
code="https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/select/SelectExample.js"
docs="https://v2.grommet.io/tag?theme=hpe"
figma=""
grommetSource="https://github.com/grommet/grommet/blob/master/src/js/components/Tag/Tag.js"
>
<TagSimple />
</Example>

1. Border
1. Value
## Use cases

Tags can have additional elements depending on the tags’ intended use and context:
### Displaying metadata
[Static tags](/components/tag#static) can be used to display non-critical, concise information with
the purpose to annotate or label items.
Tags can contain value only,
or a name value pair to assist with classification.

<Example
caption="Diagram illustrating the primary and additional elements of a tag."
plain
code="https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/select/SelectExample.js"
>
<TagAnatomy />
<TagMetaData />
</Example>

1. Border
1. Value
1. Name
1. Remove button

Character requirements:
### Managing metadata
Tags can be created, assigned and [removed](/components/tag#removable) from resources or items by a user.

- Name: up to 128 characters
- Value: up to 256 characters

### Remove button
<Example
code="https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/select/SelectExample.js"
>
<CreateTagSimple />
</Example>

Applying the remove button (see element #4 in the [anatomy figure](#anatomy)) is dependent upon the use case and not a requirement.
### Filtering
[Interactive tags](/components/tag#interactive) can be activated by mouse or keyboard input to enable quick filtering.
Interacting with the tag will display items that share the same assigned value.

The remove tag button may be used when:
<Example
code="https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/select/SelectExample.js"
>
<TagResource />
</Example>

1. Removing a tag in an editor.
1. Removing a tag as filtering criteria.
1. Clearing or removing a tag from a resource
### Drawing attention
[Highlight tags](/components/tag#highlight) can be used to draw attention to an element on the page.
They are a decorative variant of the [static tag](/components/tag#static).
Highlights should only contain descriptions that are temporary, such as “New”,
“Updated”. As such they should not be used a permanent design feature.

The remove tag button should not be used when:
<Example
code="https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/select/SelectExample.js"
>
<TagAttention />
</Example>

1. Displaying tags for a resource in a detail view. Use a [NameValueList](/components/namevaluelist) instead.
1. Displaying tags where removal of the tag is not within an edit experience for the resource.

To implement a Tag with a remove button, provide a function to the `onRemove` Tag property.

### Background color
## Anatomy

Tags do not receive a background color. Instead, tags inherit the background of their container.
<Example
caption="Diagram illustrating the four parts composing tag."
pad="small"
previewWidth="large"
height={{ min: 'small' }}
>
<TagAnatomy />
</Example>

## Name-value pair tags

Name-value pairing with tags allow further organization and identification of resources. While this feature is not a requirement, name-value pairs can help users more clearly group resources.
| Label | Region | Purpose | Required | Notes |
| :---: | ------------- | ------------------------------------------------------------ | :------: | ----------------------------------------------------------- |
| **1** | **Container** | Controls padding, border & background color. | Required | Behavior and style will change depending on tag type. |
| **2** | **Name** | Descriptive label or category that identifies what kind of data is stored in the associated value.
For example “Country” or “Color”. | Optional | Up to 128 characters max. |
| **3** | **Value** | The specific descriptive data associated with an item. 
For example “USA” or “Green”. | Required | Up to 256 characters max. |
| **4** | **Close Icon Button** | Used to indicate that tag is removable. | Optional | Required for only removable tags. |

- In some hybrid use cases, it can be valid to have a mixture of tags with name-value and others with just value.

### Creating name-value pair tags
## Types

The experience for creating a Name-Value pair tag occurs in 2 steps: Create the name and then create the value. Alternatively, select an existing name and create a new value.
### Static
- Contains simple, concise information used to annotate, categorize, group or otherwise label items.
- Used to display secondary or supplementary information related to an object or item.
- Can be used to communicate the state or condition of something (e.g. published, deployed, new, updated, etc.). State is defined [here](/components/notification#taxonomy).
- A tag should not be used to convey system status, that is considered primary information.
- Static tags are not interactive in any way.

## Assigning tags
<Example plain>
<Tag alignSelf='start' name='Type-Static' />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the types should have value styling to them. So the medium font-weight.

</Example>

Currently, assigning tags occurs within an editor experience in a [modal](/components/layer#side-drawer-modal) or [wizard](/templates/wizard). This helps to focus the task for the user. Tags are first selected and/or created, then assigned to the resource.

### Assigning value-only tags
### Interactive
- Interactive tags enable users to discover, filter, or navigate to identically tagged items.
- An interactive tag can be actioned by mouse or keyboard.

<Example
code={[
'https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/tag/CreateTagSimple.js',
'https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/tag/CreateTag/AppContainer.js',
'https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/tag/CreateTag/TagPageHeader.js',
'https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/tag/CreateTag/TagResults.js',
'https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/tag/CreateTag/utils.js',
]}
github="https://github.com/grommet/hpe-design-system/tree/master/aries-site/src/examples/components/tag/CreateTagSimple.js"
docs="https://v2.grommet.io/tag?theme=hpe#props"
showResponsiveControls={['laptop', 'mobile']}
template
>
<CreateTagSimple />
<Example plain>
<Tag alignSelf='start' onClick={() => {}} name='Type-Interactive' />
</Example>

### Assigning name-value tags
### Removable

<Example
code={[
'https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/tag/CreateTag/CreateTag.js',
'https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/tag/CreateTag/AppContainer.js',
'https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/tag/CreateTag/TagPageHeader.js',
'https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/tag/CreateTag/TagResults.js',
'https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/tag/CreateTag/utils.js',
]}
github="https://github.com/grommet/hpe-design-system/tree/master/aries-site/src/examples/components/tag/CreateTag"
docs="https://v2.grommet.io/tag?theme=hpe#props"
showResponsiveControls={['laptop', 'mobile']}
template
>
<CreateTag />
- A removable tag is interactive via the "Close" icon button.
- Can be used to dismiss a category/value set from a filtered view.
- Can be used to remove a value that has been assigned to an item or resource.
<Example plain>
<Tag alignSelf='start' name='Type-Removable' onRemove={() => {}} />
</Example>

### Highlight

## Filtering with tags

Filtering with tags allows the user to search, select, and remove tags from a set of filter criteria in order to find relevant data.

### Filtering with tags on a detail page
- Used to indicate a temporary or transient state associated with an item - eg new, updated, promotional.
- Draws attention but is no louder than a secondary/primary button.
- A highlight tag is not interactive in any way.
- A tags size should be limited to x-small or small.
- Use “blue!” border for highlight tags. This treatment should be used sparingly.
<Example plain>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

primary/blue

<Tag alignSelf='start' border={{ color: 'blue' }} name='Type-Highlight' />
</Example>

One example in which a tag can be used to facilitate quick associations amongst resources is to use the tag as a clickable filter from the detail of resource.

<Example
code={[
'https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/tag/TagResource.js',
'https://raw.githubusercontent.com/grommet/hpe-design-system/master/aries-site/src/examples/components/tag/data.js',
]}
docs="https://v2.grommet.io/tag?theme=hpe#props"
height="large"
template
showResponsiveControls={['fullScreen']}
>
<TagResource />
</Example>
## Accessibility

### Filtering with tags on a summary page

Example coming soon.
| Key | Interaction |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| **Tab** | Used to navigate between interactive tags. Focuses on tag if it is selectable. When there is a close icon present, icon receives focus. For read-only, screen reader will read alongside content from where it lives. |
| **Space/Enter** | For interactive tags, selects the tag. For removable tags, remove the tag. |
Loading
Loading