Skip to content

Commit 5a77ba9

Browse files
Merge pull request #61 from webdevnerdstuff/vuetify-v4
Vuetify v4
2 parents 7277c31 + c41bfba commit 5a77ba9

7 files changed

Lines changed: 51 additions & 15 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ dist-ssr
1414
*.local
1515

1616
# Editor directories and files
17-
.vscode/*
1817
.history/*
1918
/.claude
2019
!.vscode/extensions.json

.vscode/settings.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"explorer.fileNesting.enabled": true,
3+
"explorer.fileNesting.patterns": {
4+
"*.ts": "${capture}.js, ${capture}.js.map, ${capture}.d.ts",
5+
".env": ".env.*, .envrc",
6+
".prettierrc": ".prettierrc.*, .prettier*",
7+
"composer.json": "composer.lock, phpunit.xml*, .php-cs-fixer*, phpstan*",
8+
"eslint.config.mjs": ".eslintrc-auto-import.json, .prettierrc.*, .prettier*",
9+
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, .npmrc, .nvmrc, .node-version",
10+
"stylelint.config.js": "postcss.config.js",
11+
"tsconfig.json": "tsconfig.*.json",
12+
"vite.config.mts": "vite.build.config.mts",
13+
}
14+
}

cypress/plugins/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require('path');
22
const { startDevServer } = require('@cypress/vite-dev-server');
33

4-
module.exports = (on, config) => {
4+
module.exports = (_on, config) => {
55
config.env.tsconfigPath = path.resolve(__dirname, '../../tsconfig.cypress.json'); // Adjust the path as needed
66
return config;
77
};

src/plugin/components/fields/VSFButtonField/VSFButtonField.vue

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<span
5454
class="vsf-button-field__btn-label"
5555
:class="getLabelClass(option)"
56+
:style="getLabelStyle(option)"
5657
v-html="option.label"
5758
></span>
5859
</template>
@@ -398,9 +399,6 @@ const itemGroupStyle = computed<CSSProperties>(() => {
398399
});
399400
400401
401-
const buttontextcolor = ref('rgb(var(--v-theme-on-surface))');
402-
403-
404402
// -------------------------------------------------- Classes //
405403
const itemGroupClass = computed(() => {
406404
return {
@@ -441,13 +439,38 @@ const buttonClassAdditional = (option: Option) => {
441439
};
442440
};
443441
442+
const getLabelStyle = (option: Option): CSSProperties => {
443+
const optionVariant = getVariant(option.value);
444+
const useBgColor = isActive(option.value) || optionVariant === 'flat' || optionVariant === 'elevated';
445+
446+
// When the button shows a background color, let Vuetify's `bg-<color>`
447+
// contrast color drive the label text so a selected button gets the correct
448+
// on-color (e.g. black on a light color). Only the neutral, un-selected
449+
// state forces `on-surface` for readability.
450+
if (useBgColor) {
451+
return {};
452+
}
453+
454+
return {
455+
color: 'rgb(var(--v-theme-on-surface))',
456+
};
457+
};
458+
444459
const getLabelClass = (option: Option): object => {
445460
const isActiveOption = isActive(option.value);
446461
const optionVariant = getVariant(option.value);
447462
const useBgColor = isActiveOption || optionVariant === 'flat' || optionVariant === 'elevated';
463+
const bgColor = option?.color ?? field.value?.color;
448464
449465
return {
450-
[`bg-${option?.color}`]: useBgColor,
466+
// The field/option `class` is applied to the label itself. A
467+
// text-transform utility set directly on the label wins over the value
468+
// it would otherwise inherit from the button (e.g. a global `VBtn`
469+
// `text-uppercase` default), so the app default is respected when no
470+
// class is set but can be altered per-field/option when one is.
471+
[`bg-${bgColor}`]: useBgColor && bgColor != null,
472+
[`${field.value?.class}`]: field.value?.class != null,
473+
[`${option?.class}`]: option?.class != null,
451474
};
452475
};
453476
@@ -470,10 +493,4 @@ function containsSizeUnit(value: string | number): boolean {
470493
.v-item-group {
471494
flex-wrap: wrap;
472495
}
473-
474-
.vsf-button-field {
475-
&__btn-label {
476-
color: v-bind(buttontextcolor);
477-
}
478-
}
479496
</style>

src/shims-vue.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
declare module '*.vue';
2+
3+
// Vuetify only exposes `vuetify/styles`' type declarations via its package
4+
// `exports` map, which the classic `node` module resolution used by this
5+
// project cannot read. The import is a CSS side-effect with no meaningful
6+
// types, so declare it ambiently to satisfy the side-effect import.
7+
declare module 'vuetify/styles';

tsconfig.app.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"compilerOptions": {
33
"allowSyntheticDefaultImports": true,
4-
"baseUrl": "./",
54
"composite": true,
65
"declaration": true,
76
"declarationDir": "./dist",
@@ -86,7 +85,6 @@
8685
"src/**/__tests__/*",
8786
"playground",
8887
"src/playground/configs/templates/PlaygroundPage.vue",
89-
"src/plugins/**/*.ts",
9088
"src/stores/**/*.ts"
9189
],
9290
}

tsconfig.cypress.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"./node_modules/@types"
99
],
1010
"types": [
11-
"cypress-real-events",
11+
"cypress",
12+
"node",
1213
]
1314
},
1415
"exclude": [],
@@ -19,6 +20,7 @@
1920
"cypress/support/commands.ts",
2021
"cypress/support/component.*",
2122
"vite.cypress.config.ts",
23+
"package.json",
2224
"src/**/*",
2325
"src/**/*.vue",
2426
"src/**/__tests__/*"

0 commit comments

Comments
 (0)