fix: align field placeholder tokens and docs control semantics
This commit is contained in:
Vendored
+134
@@ -0,0 +1,134 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
Input,
|
||||
TextArea,
|
||||
InputGroup,
|
||||
InputGroupInput,
|
||||
TextField,
|
||||
SearchField,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
SearchFieldClearButton,
|
||||
NumberField,
|
||||
NumberFieldGroup,
|
||||
NumberFieldInput,
|
||||
NumberFieldDecrementButton,
|
||||
NumberFieldIncrementButton,
|
||||
} from "@heroui-vue/components";
|
||||
const token = ref("#d43f8d");
|
||||
const theme = ref("light");
|
||||
const disabled = ref(false);
|
||||
const readonly = ref(false);
|
||||
const scope = ref<HTMLElement>();
|
||||
const records = ref<string[]>([]);
|
||||
function inspect() {
|
||||
const expected = getComputedStyle(
|
||||
scope.value!.querySelector(".placeholder-expected")!,
|
||||
).color;
|
||||
records.value = Array.from(
|
||||
scope.value!.querySelectorAll<HTMLElement>("[data-placeholder-probe]"),
|
||||
).map((el) => {
|
||||
const actual = getComputedStyle(el, "::placeholder").color;
|
||||
return `${actual === expected ? "PASS" : "FAIL"} ${el.dataset.placeholderProbe}: placeholder=${actual}; expected=${expected}; text=${getComputedStyle(el).color}`;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<section
|
||||
ref="scope"
|
||||
:class="theme"
|
||||
:style="{ '--field-placeholder': token }"
|
||||
class="placeholder-lab"
|
||||
>
|
||||
<h2>原生字段占位文字主题回归</h2>
|
||||
<label>
|
||||
主题
|
||||
<select v-model="theme">
|
||||
<option>light</option>
|
||||
<option>dark</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
占位颜色
|
||||
<select v-model="token">
|
||||
<option value="#d43f8d">粉色</option>
|
||||
<option value="#2780b3">蓝色</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
<input v-model="disabled" type="checkbox" />
|
||||
禁用字段
|
||||
</label>
|
||||
<label>
|
||||
<input v-model="readonly" type="checkbox" />
|
||||
只读字段
|
||||
</label>
|
||||
<span class="placeholder-expected" style="color: var(--field-placeholder)">
|
||||
期望占位色
|
||||
</span>
|
||||
<Input
|
||||
data-placeholder-probe="Input"
|
||||
aria-label="原生输入占位"
|
||||
placeholder="输入…"
|
||||
:disabled="disabled"
|
||||
:readonly="readonly"
|
||||
/>
|
||||
<TextArea
|
||||
data-placeholder-probe="TextArea"
|
||||
aria-label="多行输入占位"
|
||||
placeholder="多行输入…"
|
||||
:disabled="disabled"
|
||||
:readonly="readonly"
|
||||
/>
|
||||
<TextField :is-disabled="disabled" :is-read-only="readonly">
|
||||
<InputGroup>
|
||||
<InputGroupInput
|
||||
data-placeholder-probe="InputGroup"
|
||||
aria-label="组合输入占位"
|
||||
placeholder="组合输入…"
|
||||
/>
|
||||
</InputGroup>
|
||||
</TextField>
|
||||
<SearchField :is-disabled="disabled" :is-read-only="readonly">
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput
|
||||
data-placeholder-probe="SearchField"
|
||||
aria-label="搜索输入占位"
|
||||
placeholder="搜索…"
|
||||
/>
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<NumberField :is-disabled="disabled" :is-read-only="readonly">
|
||||
<NumberFieldGroup>
|
||||
<NumberFieldDecrementButton />
|
||||
<NumberFieldInput
|
||||
data-placeholder-probe="NumberField"
|
||||
aria-label="数字输入占位"
|
||||
placeholder="数字…"
|
||||
/>
|
||||
<NumberFieldIncrementButton />
|
||||
</NumberFieldGroup>
|
||||
</NumberField>
|
||||
<Button @click="inspect">检查占位符颜色</Button>
|
||||
<pre aria-live="polite">{{ records.join("\n") }}</pre>
|
||||
</section>
|
||||
</template>
|
||||
<style scoped>
|
||||
.placeholder-lab {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
padding: 20px;
|
||||
border-radius: 12px;
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
}
|
||||
pre {
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user