Skip to content

Commit

Permalink
feat(slider): rename output to valueText
Browse files Browse the repository at this point in the history
  • Loading branch information
cschroeter committed Oct 24, 2023
1 parent 255e631 commit 215df8c
Show file tree
Hide file tree
Showing 23 changed files with 34 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-buckets-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zag-js/slider": patch
---

Rename output to valueText
2 changes: 1 addition & 1 deletion e2e/slider.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from "@playwright/test"
import { part, a11y, rect } from "./__utils"

const output = part("output")
const output = part("value-text")
const thumb = part("thumb")
const track = part("track")

Expand Down
2 changes: 1 addition & 1 deletion examples/next-ts/pages/range-slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function Page() {
<div {...api.rootProps}>
<div>
<label {...api.labelProps}>Quantity:</label>
<output {...api.outputProps}>{api.value.join(" - ")}</output>
<output {...api.valueTextProps}>{api.value.join(" - ")}</output>
</div>
<div className="control-area">
<div {...api.controlProps}>
Expand Down
2 changes: 1 addition & 1 deletion examples/next-ts/pages/slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function Page() {
<label data-testid="label" {...api.labelProps}>
Slider Label
</label>
<output data-testid="output" {...api.outputProps}>
<output data-testid="output" {...api.valueTextProps}>
{api.value}
</output>
</div>
Expand Down
2 changes: 1 addition & 1 deletion examples/nuxt-ts/pages/range-slider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const api = computed(() => slider.connect(state.value, send, normalizeProps))
<div v-bind="api.rootProps">
<div>
<label v-bind="api.labelProps">Quantity:</label>
<output v-bind="api.outputProps">{{ api.value.join(" - ") }}</output>
<output v-bind="api.valueTextProps">{{ api.value.join(" - ") }}</output>
</div>
<div class="control-area">
<div v-bind="api.controlProps">
Expand Down
2 changes: 1 addition & 1 deletion examples/nuxt-ts/pages/slider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const api = computed(() => slider.connect(state.value, send, normalizeProps))
<div v-bind="api.rootProps">
<div>
<label data-testid="label" v-bind="api.labelProps"> Slider Label </label>
<output data-testid="output" v-bind="api.outputProps"> {{ api.value.at(0) }} </output>
<output data-testid="output" v-bind="api.valueTextProps"> {{ api.value.at(0) }} </output>
</div>
<div class="control-area">
<div v-bind="api.controlProps">
Expand Down
6 changes: 3 additions & 3 deletions examples/solid-ts/src/pages/range-slider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { sliderControls } from "@zag-js/shared"
import * as slider from "@zag-js/slider"
import { normalizeProps, useMachine } from "@zag-js/solid"
import serialize from "form-serialize"
import { createMemo, For, createUniqueId } from "solid-js"
import { sliderControls } from "@zag-js/shared"
import { For, createMemo, createUniqueId } from "solid-js"
import { StateVisualizer } from "../components/state-visualizer"
import { Toolbar } from "../components/toolbar"
import { useControls } from "../hooks/use-controls"
Expand Down Expand Up @@ -34,7 +34,7 @@ export default function Page() {
<div {...api().rootProps}>
<div>
<label {...api().labelProps}>Quantity:</label>
<output {...api().outputProps}>{api().value.join(" - ")}</output>
<output {...api().valueTextProps}>{api().value.join(" - ")}</output>
</div>
<div class="control-area">
<div {...api().controlProps}>
Expand Down
4 changes: 2 additions & 2 deletions examples/solid-ts/src/pages/slider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { sliderControls } from "@zag-js/shared"
import * as slider from "@zag-js/slider"
import { normalizeProps, useMachine } from "@zag-js/solid"
import serialize from "form-serialize"
import { For, createMemo, createUniqueId } from "solid-js"
import { sliderControls } from "@zag-js/shared"
import { StateVisualizer } from "../components/state-visualizer"
import { Toolbar } from "../components/toolbar"
import { useControls } from "../hooks/use-controls"
Expand Down Expand Up @@ -31,7 +31,7 @@ export default function Page() {
<label data-testid="label" {...api().labelProps}>
Slider Label
</label>
<output data-testid="output" {...api().outputProps}>
<output data-testid="output" {...api().valueTextProps}>
{api().value.at(0)}
</output>
</div>
Expand Down
2 changes: 1 addition & 1 deletion examples/vue-ts/src/pages/range-slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default defineComponent({
<div {...api.rootProps}>
<div>
<label {...api.labelProps}>Quantity:</label>
<output {...api.outputProps}>{api.value.join(" - ")}</output>
<output {...api.valueTextProps}>{api.value.join(" - ")}</output>
</div>
<div class="control-area">
<div {...api.controlProps}>
Expand Down
2 changes: 1 addition & 1 deletion examples/vue-ts/src/pages/slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default defineComponent({
<label data-testid="label" {...api.labelProps}>
Slider Label
</label>
<output data-testid="output" {...api.outputProps}>
<output data-testid="output" {...api.valueTextProps}>
{api.value}
</output>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/machines/slider/src/slider.anatomy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const anatomy = createAnatomy("slider").parts(
"root",
"label",
"thumb",
"output",
"valueText",
"track",
"range",
"control",
Expand Down
6 changes: 3 additions & 3 deletions packages/machines/slider/src/slider.connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize
style: dom.getRootStyle(state.context),
}),

outputProps: normalize.output({
...parts.output.attrs,
valueTextProps: normalize.output({
...parts.valueText.attrs,
dir: state.context.dir,
"data-disabled": dataAttr(isDisabled),
"data-orientation": state.context.orientation,
"data-invalid": dataAttr(isInvalid),
"data-focus": dataAttr(isFocused),
id: dom.getOutputId(state.context),
id: dom.getValueTextId(state.context),
htmlFor: sliderValue.map((_v, i) => dom.getHiddenInputId(state.context, i)).join(" "),
"aria-live": "off",
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/machines/slider/src/slider.dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const dom = createScope({
getTrackId: (ctx: Ctx) => ctx.ids?.track ?? `slider:${ctx.id}:track`,
getRangeId: (ctx: Ctx) => ctx.ids?.range ?? `slider:${ctx.id}:range`,
getLabelId: (ctx: Ctx) => ctx.ids?.label ?? `slider:${ctx.id}:label`,
getOutputId: (ctx: Ctx) => ctx.ids?.output ?? `slider:${ctx.id}:output`,
getValueTextId: (ctx: Ctx) => ctx.ids?.valueText ?? `slider:${ctx.id}:valueText`,
getMarkerId: (ctx: Ctx, value: number) => ctx.ids?.marker?.(value) ?? `slider:${ctx.id}:marker:${value}`,

getRootEl: (ctx: Ctx) => dom.getById(ctx, dom.getRootId(ctx)),
Expand Down
4 changes: 2 additions & 2 deletions packages/machines/slider/src/slider.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type ElementIds = Partial<{
track: string
range: string
label: string
output: string
valueText: string
marker(index: number): string
}>

Expand Down Expand Up @@ -268,7 +268,7 @@ export interface MachineApi<T extends PropTypes = PropTypes> {
focus(): void
labelProps: T["label"]
rootProps: T["element"]
outputProps: T["output"]
valueTextProps: T["output"]
trackProps: T["element"]
getThumbProps(props: ThumbProps): T["element"]
getHiddenInputProps(props: ThumbProps): T["input"]
Expand Down
2 changes: 1 addition & 1 deletion shared/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ main [data-testid="scrubber"] {
width: 100%;
}

[data-scope="slider"][data-part="output"] {
[data-scope="slider"][data-part="value-text"] {
margin-inline-start: 12px;
}

Expand Down
2 changes: 1 addition & 1 deletion website/components/machines/range-slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function RangeSlider(props: any) {
<chakra.label mr="2" {...api.labelProps}>
Quantity
</chakra.label>
<output {...api.outputProps}>
<output {...api.valueTextProps}>
<b>{api.value.join(" - ")}</b>
</output>
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion website/components/machines/slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function Slider(props: any) {
<chakra.label mr="2" {...api.labelProps}>
Quantity
</chakra.label>
<output {...api.outputProps}>
<output {...api.valueTextProps}>
<b>{api.value.at(0)}</b>
</output>
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion website/data/components/range-slider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ label, control and thumb.
/* styles for control disabled state */
}

[data-part="output"][data-disabled] {
[data-part="value-text"][data-disabled] {
/* styles for output disabled state */
}

Expand Down
4 changes: 2 additions & 2 deletions website/data/components/slider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ label, control and thumb.
/* styles for control disabled state */
}

[data-part="output"][data-disabled] {
[data-part="value-text"][data-disabled] {
/* styles for output disabled state */
}

Expand Down Expand Up @@ -288,7 +288,7 @@ track, range, label, and thumb parts.
/* styles for control invalid state */
}

[data-part="output"][data-invalid] {
[data-part="valueText"][data-invalid] {
/* styles for output invalid state */
}

Expand Down
2 changes: 1 addition & 1 deletion website/data/snippets/react/slider/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function Slider() {
<div {...api.rootProps}>
<div>
<label {...api.labelProps}>Slider Label</label>
<output {...api.outputProps}>{api.value.at(0)}</output>
<output {...api.valueTextProps}>{api.value.at(0)}</output>
</div>
<div {...api.controlProps}>
<div {...api.trackProps}>
Expand Down
2 changes: 1 addition & 1 deletion website/data/snippets/solid/slider/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function Slider() {
<div {...api().rootProps}>
<div>
<label {...api().labelProps}>Slider Label</label>
<output {...api().outputProps}>{api().value.at(0)}</output>
<output {...api().valueTextProps}>{api().value.at(0)}</output>
</div>
<div {...api().controlProps}>
<div {...api().trackProps}>
Expand Down
2 changes: 1 addition & 1 deletion website/data/snippets/vue-jsx/slider/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default defineComponent({
<div {...api.rootProps}>
<div>
<label {...api.labelProps}>Slider Label</label>
<output {...api.outputProps}>{api.value.at(0)}</output>
<output {...api.valueTextProps}>{api.value.at(0)}</output>
</div>
<div {...api.controlProps}>
<div {...api.trackProps}>
Expand Down
2 changes: 1 addition & 1 deletion website/data/snippets/vue-sfc/slider/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const api = computed(() => slider.connect(state.value, send, normalizeProps));
<div ref="ref" v-bind="api.rootProps">
<div>
<label v-bind="api.labelProps">Slider Label</label>
<output v-bind="api.outputProps">{{ api.value.at(0) }}</output>
<output v-bind="api.valueTextProps">{{ api.value.at(0) }}</output>
</div>
<div v-bind="api.controlProps">
<div v-bind="api.trackProps">
Expand Down

4 comments on commit 215df8c

@vercel
Copy link

@vercel vercel bot commented on 215df8c Oct 24, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 215df8c Oct 24, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

zag-solid – ./examples/solid-ts

zag-solid.vercel.app
zag-solid-chakra-ui.vercel.app
zag-solid-git-main-chakra-ui.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 215df8c Oct 24, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

zag-vue – ./examples/vue-ts

zag-vue-git-main-chakra-ui.vercel.app
zag-vue.vercel.app
zag-vue-chakra-ui.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 215df8c Oct 24, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

zag-nextjs – ./examples/next-ts

zag-nextjs-git-main-chakra-ui.vercel.app
zag-nextjs-chakra-ui.vercel.app
zag-two.vercel.app

Please sign in to comment.