1 | The friendly-wrap component lets you wrap text in a predictable way by appending [`<wbr>`] elements
|
2 | to specific break-symbols.
|
3 |
|
4 | [`<wbr>`]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr
|
5 |
|
6 | ## Internet Explorer 11
|
7 |
|
8 | IE11 doesn't support the `<wbr>` element: <https://caniuse.com/#search=wbr>
|
9 | To use this component on IE11, you'll need some CSS to preserve its behaviour:
|
10 |
|
11 | ```css
|
12 | wbr {
|
13 | display: inline-block;
|
14 | }
|
15 | ```
|
16 |
|
17 | ## Usage
|
18 |
|
19 | ### Default
|
20 |
|
21 | By default, `GlFriendlyWrap` wraps text with slashes (`/`) as the break-symbol, which is especially
|
22 | useful when displaying paths or URLs:
|
23 |
|
24 | ```html
|
25 | <gl-friendly-wrap text="/some/file/path" />
|
26 | ```
|
27 |
|
28 | The code above renders to the following HTML:
|
29 |
|
30 | ```html
|
31 | <span class="text-break">/<wbr>some/<wbr>file/<wbr>path</span>
|
32 | ```
|
33 |
|
34 | ### Custom symbols
|
35 |
|
36 | Multiple custom break-symbols can be defined via the `GlFriendlyWrap` prop:
|
37 |
|
38 | ```html
|
39 | <gl-friendly-wrap
|
40 | :symbols="[';', '-', '.']"
|
41 | text="some;text-that.needs;to-be.wrapped"
|
42 | />
|
43 | ```
|
44 |
|
45 | Which renders to:
|
46 |
|
47 | ```html
|
48 | <span class="text-break">some;<wbr>text-<wbr>that.<wbr>needs;<wbr>to-<wbr>be.<wbr>wrapped</span>
|
49 | ```
|
50 |
|
51 | ### Break words
|
52 |
|
53 | Symbols can be words too:
|
54 |
|
55 | ```html
|
56 | <gl-friendly-wrap
|
57 | :symbols="['and']"
|
58 | text="it goes on and on and on and on"
|
59 | />
|
60 | ```
|
61 |
|
62 | Which renders to:
|
63 |
|
64 | ```html
|
65 | <span class="text-break">it goes on and<wbr> on and<wbr> on and<wbr> on</span>
|
66 | ```
|