Skip to content

Commit

Permalink
refactor(admin/components): 调整组件样式
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Oct 6, 2024
1 parent f36abb2 commit 21a2f4e
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 63 deletions.
7 changes: 3 additions & 4 deletions admin/src/components/form/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface Props extends FieldBaseProps {
}

const presetProps: Partial<Props> = {
tabindex: 0,
checkedIcon: 'check_box',
uncheckedIcon: 'check_box_outline_blank',
indeterminateIcon: 'indeterminate_check_box'
Expand All @@ -34,18 +35,16 @@ export default function(props: Props) {
props = mergeProps(presetProps, props);
const [chk, setChk] = createSignal(props.checked);

return <label title={props.title} classList={{
return <label tabIndex={props.tabindex} accessKey={props.accessKey} title={props.title} classList={{
'c--checkbox': true,
'c--checkbox-border': props.block,
[`palette--${props.palette}`]: !!props.palette
}}>
<input type="checkbox"
accessKey={props.accessKey}
tabIndex={props.tabindex}
readOnly={props.readonly}
disabled={props.disabled}
checked={chk()}
class="appearance-none"
class="appearance-none hidden"
onChange={() => {
if (!props.readonly && !props.disabled) {
setChk(!chk());
Expand Down
7 changes: 5 additions & 2 deletions admin/src/components/form/checkbox/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
@apply border-[var(--fg-low)] rounded-sm has-[:checked]:border-[var(--bg)];
}

.c--checkbox:focus-within .checkbox-icon {
color: var(--fg-high);
.c--checkbox:focus-visible {
outline: none;
.checkbox-icon {
color: var(--fg-high);
}
}

.c--checkbox:has(:enabled):hover {
Expand Down
4 changes: 2 additions & 2 deletions admin/src/components/form/radio/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface Props<T> extends FieldBaseProps {

export default function Group<T extends string | number | undefined> (props: Props<T>) {
props = mergeProps({
tabindex: 0,
checkedIcon: 'radio_button_checked',
uncheckedIcon: 'radio_button_unchecked'
}, props);
Expand All @@ -42,10 +43,9 @@ export default function Group<T extends string | number | undefined> (props: Pro
}}>
<For each={props.options}>
{(item) =>
<label classList={{'border': props.block}}>
<label classList={{'border': props.block}} tabIndex={props.tabindex} accessKey={props.accessKey}>
<input type="radio" class="appearance-none"
readOnly={props.readonly}
tabIndex={props.tabindex}
checked={item[0] === access.getValue()}
name={props.accessor.name()}
value={item[0]}
Expand Down
8 changes: 6 additions & 2 deletions admin/src/components/form/radio/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
cursor: pointer;
}

label:focus-within .radio-icon {
color: var(--bg-low);
label:focus-visible {
outline: none;

.radio-icon {
color: var(--fg-high);
}
}

label.border {
Expand Down
106 changes: 55 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"lint": "eslint"
},
"devDependencies": {
"@stylistic/eslint-plugin-ts": "^2.8.0",
"eslint": "^9.11.1",
"@stylistic/eslint-plugin-ts": "^2.9.0",
"eslint": "^9.12.0",
"globals": "^15.10.0",
"typescript-eslint": "^8.8.0"
}
Expand Down

0 comments on commit 21a2f4e

Please sign in to comment.