fix: align field placeholder tokens and docs control semantics
This commit is contained in:
@@ -36,6 +36,7 @@ import {
|
|||||||
PopoverHeading,
|
PopoverHeading,
|
||||||
ScrollShadow,
|
ScrollShadow,
|
||||||
} from "@heroui-vue/components";
|
} from "@heroui-vue/components";
|
||||||
|
import { buttonVariants } from "@heroui-vue/styles";
|
||||||
import {
|
import {
|
||||||
IconMenu2,
|
IconMenu2,
|
||||||
IconArrowUpRight,
|
IconArrowUpRight,
|
||||||
@@ -240,17 +241,17 @@ async function copyMarkdownCode(event: MouseEvent) {
|
|||||||
</div>
|
</div>
|
||||||
<DocSearch />
|
<DocSearch />
|
||||||
<div class="nav-tools">
|
<div class="nav-tools">
|
||||||
<Button as-child variant="tertiary" size="sm" class="docs-github">
|
<Link
|
||||||
<a
|
class="docs-github"
|
||||||
href="https://git.myjdemo.cn/maoyingjie/heroui-vue"
|
:class="buttonVariants({ variant: 'tertiary', size: 'sm' })"
|
||||||
target="_blank"
|
href="https://git.myjdemo.cn/maoyingjie/heroui-vue"
|
||||||
rel="noreferrer noopener"
|
target="_blank"
|
||||||
aria-label="项目源码"
|
rel="noreferrer noopener"
|
||||||
>
|
aria-label="项目源码"
|
||||||
<IconBrandGithub :size="16" aria-hidden="true" />
|
>
|
||||||
<span>源码</span>
|
<IconBrandGithub :size="16" aria-hidden="true" />
|
||||||
</a>
|
<span>源码</span>
|
||||||
</Button>
|
</Link>
|
||||||
<DocsThemeSwitch />
|
<DocsThemeSwitch />
|
||||||
<Drawer v-model:open="mobile">
|
<Drawer v-model:open="mobile">
|
||||||
<DrawerTrigger as-child>
|
<DrawerTrigger as-child>
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ html {
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
.docs-nav .brand {
|
.docs-nav .brand {
|
||||||
|
text-decoration: none;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
@@ -252,6 +253,7 @@ html {
|
|||||||
margin: -8px 0 32px;
|
margin: -8px 0 32px;
|
||||||
}
|
}
|
||||||
.source-links .hv-link {
|
.source-links .hv-link {
|
||||||
|
text-decoration: none;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
@@ -419,6 +421,7 @@ html {
|
|||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
}
|
}
|
||||||
.component-index-title {
|
.component-index-title {
|
||||||
|
text-decoration: none;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
@@ -549,6 +552,7 @@ html {
|
|||||||
scrollbar-width: thin;
|
scrollbar-width: thin;
|
||||||
}
|
}
|
||||||
.search-results .hv-link {
|
.search-results .hv-link {
|
||||||
|
text-decoration: none;
|
||||||
display: block;
|
display: block;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
TableCell,
|
TableCell,
|
||||||
} from "@heroui-vue/components";
|
} from "@heroui-vue/components";
|
||||||
import { buttonVariants, tv } from "@heroui-vue/styles";
|
import { buttonVariants, tv } from "@heroui-vue/styles";
|
||||||
|
import FieldPlaceholder from "../../../tests/fixtures/field-placeholder.vue";
|
||||||
|
|
||||||
const root = ref<HTMLElement>();
|
const root = ref<HTMLElement>();
|
||||||
const local = ref<HTMLElement>();
|
const local = ref<HTMLElement>();
|
||||||
@@ -368,6 +369,7 @@ onBeforeUnmount(() => {
|
|||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<pre aria-live="polite" id="audit-results">{{ records.join("\n") }}</pre>
|
<pre aria-live="polite" id="audit-results">{{ records.join("\n") }}</pre>
|
||||||
|
<FieldPlaceholder />
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.hv-number-field__input {
|
.hv-number-field__input {
|
||||||
@apply min-w-0 rounded-none border-0 bg-transparent px-3 py-2 text-base tabular-nums shadow-none outline-none sm:text-sm;
|
@apply min-w-0 rounded-none border-0 bg-transparent px-3 py-2 text-base tabular-nums shadow-none outline-none placeholder:text-field-placeholder sm:text-sm;
|
||||||
|
|
||||||
/* Remove border radius on left side when decrement button is present */
|
/* Remove border radius on left side when decrement button is present */
|
||||||
.hv-number-field__group:has([slot="decrement"]) & {
|
.hv-number-field__group:has([slot="decrement"]) & {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.hv-search-field__input {
|
.hv-search-field__input {
|
||||||
@apply flex-1 rounded-none border-0 bg-transparent px-3 py-2 text-base shadow-none outline-none sm:text-sm;
|
@apply flex-1 rounded-none border-0 bg-transparent px-3 py-2 text-base shadow-none outline-none placeholder:text-field-placeholder sm:text-sm;
|
||||||
|
|
||||||
/* Hide browser default search clear button */
|
/* Hide browser default search clear button */
|
||||||
&::-webkit-search-cancel-button,
|
&::-webkit-search-cancel-button,
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
// Add the browser regression to an already-installed check-package consumer.
|
||||||
|
// Installation/tarball preparation stays exclusively in check-package.mjs.
|
||||||
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
const root = path.resolve(import.meta.dirname, "..");
|
||||||
|
const consumer = path.resolve(process.argv[2] ?? "");
|
||||||
|
if (
|
||||||
|
!process.argv[2] ||
|
||||||
|
consumer === root ||
|
||||||
|
!fs.existsSync(path.join(consumer, "check-client.mjs")) ||
|
||||||
|
!fs.existsSync(
|
||||||
|
path.join(consumer, "node_modules/@heroui-vue/components/package.json"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
throw Error(
|
||||||
|
"Pass the independent consumer directory printed by node scripts/check-package.mjs handbook-styles",
|
||||||
|
);
|
||||||
|
fs.copyFileSync(
|
||||||
|
path.join(root, "tests/fixtures/field-placeholder.vue"),
|
||||||
|
path.join(consumer, "field-placeholder.vue"),
|
||||||
|
);
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(consumer, "main.js"),
|
||||||
|
'import {createApp} from "vue";\nimport App from "./field-placeholder.vue";\nimport "@heroui-vue/styles/css";\ncreateApp(App).mount("#app");\n',
|
||||||
|
);
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(consumer, "index.html"),
|
||||||
|
'<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Published field placeholder regression</title></head><body><div id="app"></div><script type="module" src="/main.js"></script></body></html>',
|
||||||
|
);
|
||||||
|
const plugin = fileURLToPath(import.meta.resolve("@vitejs/plugin-vue"));
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(consumer, "vite.config.js"),
|
||||||
|
`import vue from ${JSON.stringify(plugin)};\nexport default { plugins:[vue()], resolve:{dedupe:["vue"]} };\n`,
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`Browser fixture prepared at ${consumer}. Components/styles resolve only from installed tarballs; Vite/Vue compilation tooling is shared.`,
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`Run the workspace Vite CLI with this directory as cwd, host 127.0.0.1 and an unused explicit port.`,
|
||||||
|
);
|
||||||
@@ -120,6 +120,8 @@ it("uses a native version trigger, button-styled source anchor and detached them
|
|||||||
expect(version.element.tagName).toBe("BUTTON");
|
expect(version.element.tagName).toBe("BUTTON");
|
||||||
const source = w.get('[aria-label="项目源码"]');
|
const source = w.get('[aria-label="项目源码"]');
|
||||||
expect(source.element.tagName).toBe("A");
|
expect(source.element.tagName).toBe("A");
|
||||||
|
expect(source.classes()).toContain("hv-link");
|
||||||
|
expect(source.attributes("type")).toBeUndefined();
|
||||||
expect(source.attributes("href")).toBe(
|
expect(source.attributes("href")).toBe(
|
||||||
"https://git.myjdemo.cn/maoyingjie/heroui-vue",
|
"https://git.myjdemo.cn/maoyingjie/heroui-vue",
|
||||||
);
|
);
|
||||||
|
|||||||
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