|
| 1 | +import * as React from "react"; |
| 2 | +import { useStyletron } from "baseui"; |
| 3 | +import { Tag, SUPPORTED_KIND } from "baseui/tag"; |
| 4 | +import { TagGroup } from "baseui/tag-group"; |
| 5 | +import { HeadingSmall, ParagraphSmall } from "baseui/typography"; |
| 6 | + |
| 7 | +export default function Example() { |
| 8 | + const [css] = useStyletron(); |
| 9 | + return ( |
| 10 | + <React.Fragment> |
| 11 | + <HeadingSmall>Wrap: true (default)</HeadingSmall> |
| 12 | + |
| 13 | + <ParagraphSmall>no width set on container</ParagraphSmall> |
| 14 | + <TagGroup> |
| 15 | + {Object.values(SUPPORTED_KIND) |
| 16 | + .filter((kind) => kind !== SUPPORTED_KIND.custom) |
| 17 | + .map((kind) => ( |
| 18 | + <Tag key={kind} kind={kind}> |
| 19 | + {kind} |
| 20 | + </Tag> |
| 21 | + ))} |
| 22 | + </TagGroup> |
| 23 | + |
| 24 | + <ParagraphSmall>width set to 300px on container </ParagraphSmall> |
| 25 | + <div className={css({ width: "300px" })}> |
| 26 | + <TagGroup> |
| 27 | + {Object.values(SUPPORTED_KIND) |
| 28 | + .filter((kind) => kind !== SUPPORTED_KIND.custom) |
| 29 | + .map((kind) => ( |
| 30 | + <Tag key={kind} kind={kind}> |
| 31 | + {kind} |
| 32 | + </Tag> |
| 33 | + ))} |
| 34 | + </TagGroup> |
| 35 | + </div> |
| 36 | + |
| 37 | + <ParagraphSmall> |
| 38 | + width set to 300px on container and tag with long text{" "} |
| 39 | + </ParagraphSmall> |
| 40 | + <div className={css({ width: "300px" })}> |
| 41 | + <TagGroup> |
| 42 | + {Object.values(SUPPORTED_KIND) |
| 43 | + .filter((kind) => kind !== SUPPORTED_KIND.custom) |
| 44 | + .map((kind, index) => ( |
| 45 | + <Tag key={kind} kind={kind}> |
| 46 | + {index === 1 |
| 47 | + ? "A very long tag text to test wrapping behavior" |
| 48 | + : kind} |
| 49 | + </Tag> |
| 50 | + ))} |
| 51 | + </TagGroup> |
| 52 | + </div> |
| 53 | + |
| 54 | + <ParagraphSmall> |
| 55 | + width set to 100px(smaller than tag text default max width) on container |
| 56 | + and tag with long text - very extreme case |
| 57 | + </ParagraphSmall> |
| 58 | + <div className={css({ marginBottom: "40px", width: "100px" })}> |
| 59 | + <TagGroup> |
| 60 | + {Object.values(SUPPORTED_KIND) |
| 61 | + .filter((kind) => kind !== SUPPORTED_KIND.custom) |
| 62 | + .map((kind, index) => ( |
| 63 | + <Tag key={kind} kind={kind}> |
| 64 | + {index === 1 |
| 65 | + ? "A very long tag text to test wrapping behavior" |
| 66 | + : kind} |
| 67 | + </Tag> |
| 68 | + ))} |
| 69 | + </TagGroup> |
| 70 | + </div> |
| 71 | + |
| 72 | + <HeadingSmall>Wrap: false</HeadingSmall> |
| 73 | + <ParagraphSmall>no width set on container</ParagraphSmall> |
| 74 | + <TagGroup> |
| 75 | + {Object.values(SUPPORTED_KIND) |
| 76 | + .filter((kind) => kind !== SUPPORTED_KIND.custom) |
| 77 | + .map((kind) => ( |
| 78 | + <Tag key={kind} kind={kind}> |
| 79 | + {kind} |
| 80 | + </Tag> |
| 81 | + ))} |
| 82 | + </TagGroup> |
| 83 | + |
| 84 | + <ParagraphSmall>width set to 300px on container </ParagraphSmall> |
| 85 | + <div className={css({ width: "300px" })}> |
| 86 | + <TagGroup wrap={false}> |
| 87 | + {Object.values(SUPPORTED_KIND) |
| 88 | + .filter((kind) => kind !== SUPPORTED_KIND.custom) |
| 89 | + .map((kind) => ( |
| 90 | + <Tag key={kind} kind={kind}> |
| 91 | + {kind} |
| 92 | + </Tag> |
| 93 | + ))} |
| 94 | + </TagGroup> |
| 95 | + </div> |
| 96 | + |
| 97 | + <ParagraphSmall> |
| 98 | + width set to 300px on container and tag with long text{" "} |
| 99 | + </ParagraphSmall> |
| 100 | + <div className={css({ marginBottom: "40px", width: "300px" })}> |
| 101 | + <TagGroup wrap={false}> |
| 102 | + {Object.values(SUPPORTED_KIND) |
| 103 | + .filter((kind) => kind !== SUPPORTED_KIND.custom) |
| 104 | + .map((kind, index) => ( |
| 105 | + <Tag key={kind} kind={kind}> |
| 106 | + {index === 1 |
| 107 | + ? "A very long tag text to test wrapping behavior" |
| 108 | + : kind} |
| 109 | + </Tag> |
| 110 | + ))} |
| 111 | + </TagGroup> |
| 112 | + </div> |
| 113 | + </React.Fragment> |
| 114 | + ); |
| 115 | +} |
0 commit comments