Skip to content

Commit

Permalink
fix: use space internally
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanSalt committed Jul 17, 2023
1 parent 3e75649 commit 9fb61ee
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 28 deletions.
2 changes: 1 addition & 1 deletion docs/components/card.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ import { RCard } from 'roughness'
Horizontal padding of the card.
</template>

<template #body:....name>..:</template>
<template #body:....name>...</template>
<template #body:...:description>

See [Space Styles](/components/space#styles).
Expand Down
25 changes: 20 additions & 5 deletions docs/components/checkbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ const treeValue = ref<string | undefined>()
<RSpace overflow>
<RTable
:columns="['name', 'type', 'default', 'description']"
:rows="['checked', 'graphics-options', 'indeterminate', 'label', 'reactions', 'value']"
:rows="['checked', 'graphics-options', 'indeterminate', 'label', 'reactions', 'value', '...']"
>
<template #body:*:name="{ row }">{{ row }}</template>
Expand Down Expand Up @@ -244,12 +244,12 @@ const treeValue = ref<string | undefined>()

</template>

<template #body:value:type>
<template #body:label:type>

`string`

</template>
<template #body:value:description>
<template #body:label:description>
Item label when checked and displayed, e.g. in Select.
</template>

Expand Down Expand Up @@ -295,6 +295,14 @@ const treeValue = ref<string | undefined>()
<template #body:value:description>
Item value when checked in the CheckboxGroup.
</template>

<template #body:...:description>

See [Space Props](/components/space#props).

Unlike Space, the default value of Checkbox's `tag` is `label`.

</template>
</RTable>
</RSpace>

Expand Down Expand Up @@ -338,7 +346,7 @@ const treeValue = ref<string | undefined>()
<RSpace overflow>
<RTable
:columns="['name', 'values', 'default', 'description']"
:rows="['border-color', 'border-width', 'checked-color', 'checked-width', 'control-size']"
:rows="['border-color', 'border-width', 'checked-color', 'checked-width', 'control-size', '...']"
>
<template #body:*:name="{ row }">--r-checkbox-{{ row }}</template>
Expand Down Expand Up @@ -411,6 +419,13 @@ const treeValue = ref<string | undefined>()
<template #body:control-size:description>
Size of the checkbox control.
</template>

<template #body:....name>...</template>
<template #body:...:description>

See [Space Styles](/components/space#styles).

</template>
</RTable>
</RSpace>

Expand Down Expand Up @@ -486,7 +501,7 @@ const treeValue = ref<string | undefined>()
>
<template #body:*:name="{ row }">--r-checkbox-group-{{ row }}</template>
<template #body:....name>..:</template>
<template #body:....name>...</template>
<template #body:...:description>

See [Space Styles](/components/space#styles).
Expand Down
2 changes: 1 addition & 1 deletion docs/components/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function show() {
>
<template #body:*:name="{ row }">--r-dialog-{{ row }}</template>
<template #body:....name>..:</template>
<template #body:....name>...</template>
<template #body:...:description>

See [Card Styles](/components/card#styles).
Expand Down
2 changes: 1 addition & 1 deletion docs/components/drawer.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function showBottom() {
>
<template #body:*:name="{ row }">--r-drawer-{{ row }}</template>
<template #body:....name>..:</template>
<template #body:....name>...</template>
<template #body:...:description>

See [Dialog Styles](/components/dialog#styles).
Expand Down
2 changes: 1 addition & 1 deletion docs/components/icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ See [Text](/components/text).
Color of the icon.
</template>

<template #body:....name>..:</template>
<template #body:....name>...</template>
<template #body:...:description>

See [Text Styles](/components/text#styles).
Expand Down
2 changes: 1 addition & 1 deletion docs/components/link.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ See also [Button](/components/button#tag).

</template>

<template #body:....name>..:</template>
<template #body:....name>...</template>
<template #body:...:description>

See [Text Styles](/components/text#styles).
Expand Down
2 changes: 1 addition & 1 deletion docs/components/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ import { RList, RListItem } from 'roughness'
Area width of the list marker.
</template>

<template #body:....name>..:</template>
<template #body:....name>...</template>
<template #body:...:description>

See [Space Styles](/components/space#styles).
Expand Down
19 changes: 17 additions & 2 deletions docs/components/switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { RSwitch } from 'roughness'
<RSpace overflow>
<RTable
:columns="['name', 'type', 'default', 'description']"
:rows="['graphics-options', 'model-value', 'reactions']"
:rows="['graphics-options', 'model-value', 'reactions', '...']"
>
<template #body:*:name="{ row }">{{ row }}</template>
Expand Down Expand Up @@ -80,6 +80,14 @@ import { RSwitch } from 'roughness'
See [Reactions](/guide/theme#reactions).

</template>

<template #body:...:description>

See [Space Props](/components/space#props).

Unlike Space, the default value of Switch's `tag` is `label`.

</template>
</RTable>
</RSpace>

Expand Down Expand Up @@ -123,7 +131,7 @@ import { RSwitch } from 'roughness'
<RSpace overflow>
<RTable
:columns="['name', 'values', 'default', 'description']"
:rows="['border-color', 'border-width', 'control-size', 'track-color', 'handle-color']"
:rows="['border-color', 'border-width', 'control-size', 'track-color', 'handle-color', '...']"
>
<template #body:*:name="{ row }">--r-switch-{{ row }}</template>
Expand Down Expand Up @@ -196,5 +204,12 @@ import { RSwitch } from 'roughness'
<template #body:handle-color:description>
Color of the switch handle.
</template>

<template #body:....name>...</template>
<template #body:...:description>

See [Space Styles](/components/space#styles).

</template>
</RTable>
</RSpace>
11 changes: 5 additions & 6 deletions src/checkbox/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useReactionState } from '../common/utils'
import RGraphics from '../graphics/index.vue'
import type { GraphicsProps } from '../graphics/utils'
import { getFilledSizeOptions, getSVGSize, measureSVGSize } from '../graphics/utils'
import RSpace from '../space/index.vue'
import type { CheckboxValue } from './utils'
import { labelsInjection, modelInjection, multipleInjection } from './utils'
Expand Down Expand Up @@ -117,7 +118,7 @@ function draw(rc: RoughSVG, svg: SVGSVGElement) {
</script>

<template>
<label class="r-checkbox">
<RSpace tag="label" inline class="r-checkbox">
<input
v-model="internalChecked"
:type="multiple === false ? 'radio' : 'checkbox'"
Expand All @@ -130,7 +131,7 @@ function draw(rc: RoughSVG, svg: SVGSVGElement) {
<RGraphics :options="graphicsOptions" @draw="draw" />
</span>
<slot>{{ label }}</slot>
</label>
</RSpace>
</template>

<style lang="scss" scoped>
Expand All @@ -140,7 +141,7 @@ function draw(rc: RoughSVG, svg: SVGSVGElement) {
--r-checkbox-checked-color: var(--r-common-primary-color);
--r-checkbox-checked-width: 2px;
--r-checkbox-control-size: var(--r-common-line-height);
display: inline-flex;
position: relative;
cursor: pointer;
&:focus-within,
&:not(:has(> .r-checkbox__input:disabled)):active {
Expand All @@ -153,15 +154,13 @@ function draw(rc: RoughSVG, svg: SVGSVGElement) {
}
.r-checkbox__input {
appearance: none;
position: absolute;
margin: 0;
}
.r-checkbox__control {
flex: none;
width: var(--r-checkbox-control-size);
height: var(--r-checkbox-control-size);
&:not(:last-child) {
margin-inline-end: calc(var(--r-checkbox-control-size) / 4);
}
.r-checkbox__input:disabled + & {
opacity: 0.8;
}
Expand Down
6 changes: 3 additions & 3 deletions src/details/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useReactionState } from '../common/utils'
import RGraphics from '../graphics/index.vue'
import type { GraphicsProps } from '../graphics/utils'
import { getSVGSize } from '../graphics/utils'
import RSpace from '../space/index.vue'
defineOptions({
name: 'RDetails',
Expand Down Expand Up @@ -73,12 +74,12 @@ function draw(rc: RoughSVG, svg: SVGSVGElement) {
class="r-details"
@toggle="toggle"
>
<summary ref="summary" class="r-details__summary">
<RSpace ref="summary" tag="summary" class="r-details__summary">
<span class="r-details__summary-marker">
<RGraphics :options="graphicsOptions" @draw="draw" />
</span>
<slot name="summary"></slot>
</summary>
</RSpace>
<slot></slot>
</details>
</template>
Expand Down Expand Up @@ -107,7 +108,6 @@ function draw(rc: RoughSVG, svg: SVGSVGElement) {
flex: none;
width: var(--r-details-summary-marker-size);
height: var(--r-details-summary-marker-size);
margin-inline-end: calc(var(--r-details-summary-marker-size) / 4);
pointer-events: none;
}
</style>
11 changes: 5 additions & 6 deletions src/switch/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useReactionState } from '../common/utils'
import RGraphics from '../graphics/index.vue'
import type { GraphicsProps } from '../graphics/utils'
import { getFilledSizeOptions, getSVGSize, measureSVGSize } from '../graphics/utils'
import RSpace from '../space/index.vue'
defineOptions({
name: 'RSwitch',
Expand Down Expand Up @@ -80,7 +81,7 @@ function draw(rc: RoughSVG, svg: SVGSVGElement) {
</script>

<template>
<label class="r-switch">
<RSpace tag="label" inline class="r-switch">
<input
v-model="internalModelValue"
:disabled="disabled"
Expand All @@ -91,7 +92,7 @@ function draw(rc: RoughSVG, svg: SVGSVGElement) {
<RGraphics :options="graphicsOptions" @draw="draw" />
</span>
<slot></slot>
</label>
</RSpace>
</template>

<style lang="scss" scoped>
Expand All @@ -101,7 +102,7 @@ function draw(rc: RoughSVG, svg: SVGSVGElement) {
--r-switch-control-size: var(--r-common-line-height);
--r-switch-track-color: var(--r-common-primary-color);
--r-switch-handle-color: var(--r-common-background-color);
display: inline-flex;
position: relative;
cursor: pointer;
&:focus-within,
&:not(:has(> .r-checkbox__input:disabled)):active {
Expand All @@ -114,15 +115,13 @@ function draw(rc: RoughSVG, svg: SVGSVGElement) {
}
.r-switch__input {
appearance: none;
position: absolute;
margin: 0;
}
.r-switch__control {
flex: none;
width: calc(var(--r-switch-control-size) * 2);
height: var(--r-switch-control-size);
&:not(:last-child) {
margin-inline-end: calc(var(--r-switch-control-size) / 4);
}
.r-switch__input:disabled + & {
opacity: 0.8;
}
Expand Down

0 comments on commit 9fb61ee

Please sign in to comment.