-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(w): add
<SW>
(word) component (#378)
- Loading branch information
Showing
8 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# SW <Badge text="3.3.0" /> | ||
|
||
`<SW>`, where "W" stands for "Word", is a simple helper component that marks separated words as a single word and prevent them from being word broken. See in action on [Histoire](https://story.sefirot.globalbrains.com/story/stories-components-sw-01-playground-story-vue). | ||
|
||
## Overview | ||
|
||
Use this component to prevent word breaks for certain words. Mainly useful when building marketing sites in Japanese. | ||
|
||
## Import | ||
|
||
```ts | ||
import SW from '@globalbrain/sefirot/lib/components/SW.vue' | ||
``` | ||
|
||
## Usage | ||
|
||
Wrap any words within this component to prevent them from being word broken. Under the hood, it will inject `<wbr>` and wrap the content in `<span>` with `white-space: nowrap`. | ||
|
||
```vue-html | ||
<p> | ||
When resizing the container, <SW>This word</SW> should not be | ||
word borken and should be treated as a single word. | ||
</p> | ||
``` | ||
|
||
## Slots | ||
|
||
### `#default` | ||
|
||
`<SM>` will render any passed slot by wrapping it with `<span>` | ||
|
||
```vue-html | ||
<SW>...</SW> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Utility Classes | ||
|
||
Sefirot comes with few utility CSS classes. Most of the time, there should be a Vue Component that applies these classes, so prefere using them over directly using the CSS classes. | ||
|
||
All Sefirot utility classes are prefixed with `u-`. | ||
|
||
## Whitespace | ||
|
||
### `u-nowrap` <Badge text="3.3.0" /> | ||
|
||
```css | ||
.u-nowrap { | ||
white-space: nowrap; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
<wbr><span class="u-nowrap"><slot /></span> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
@import "./variables-deprecated"; | ||
@import "./variables"; | ||
@import "./base"; | ||
@import "./utilities"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.u-nowrap { | ||
white-space: nowrap; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script setup lang="ts"> | ||
import SW from 'sefirot/components/SW.vue' | ||
const title = 'Components / SW / 01. Playground' | ||
</script> | ||
|
||
<template> | ||
<Story :title="title" source="Not available" auto-props-disabled> | ||
<Board :title="title"> | ||
<p class="max-w-512">Resize the window and try line breaking this text line. <SW><span class="text-c-info-1">This word</span></SW> should not be word borken and should be treated as a single word. For another example, <SW><span class="text-c-info-1">this word</span></SW> should also be broke together.</p> | ||
</Board> | ||
</Story> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters