Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dist-ssr
*.local

# Editor directories and files
.vscode/*
.history/*
/.claude
!.vscode/extensions.json
Expand Down
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*.ts": "${capture}.js, ${capture}.js.map, ${capture}.d.ts",
".env": ".env.*, .envrc",
".prettierrc": ".prettierrc.*, .prettier*",
"composer.json": "composer.lock, phpunit.xml*, .php-cs-fixer*, phpstan*",
"eslint.config.mjs": ".eslintrc-auto-import.json, .prettierrc.*, .prettier*",
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, .npmrc, .nvmrc, .node-version",
"stylelint.config.js": "postcss.config.js",
"tsconfig.json": "tsconfig.*.json",
"vite.config.mts": "vite.build.config.mts",
}
}
2 changes: 1 addition & 1 deletion cypress/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path');
const { startDevServer } = require('@cypress/vite-dev-server');

module.exports = (on, config) => {
module.exports = (_on, config) => {
config.env.tsconfigPath = path.resolve(__dirname, '../../tsconfig.cypress.json'); // Adjust the path as needed
return config;
};
37 changes: 27 additions & 10 deletions src/plugin/components/fields/VSFButtonField/VSFButtonField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<span
class="vsf-button-field__btn-label"
:class="getLabelClass(option)"
:style="getLabelStyle(option)"
v-html="option.label"
></span>
</template>
Expand Down Expand Up @@ -398,9 +399,6 @@ const itemGroupStyle = computed<CSSProperties>(() => {
});


const buttontextcolor = ref('rgb(var(--v-theme-on-surface))');


// -------------------------------------------------- Classes //
const itemGroupClass = computed(() => {
return {
Expand Down Expand Up @@ -441,13 +439,38 @@ const buttonClassAdditional = (option: Option) => {
};
};

const getLabelStyle = (option: Option): CSSProperties => {
const optionVariant = getVariant(option.value);
const useBgColor = isActive(option.value) || optionVariant === 'flat' || optionVariant === 'elevated';

// When the button shows a background color, let Vuetify's `bg-<color>`
// contrast color drive the label text so a selected button gets the correct
// on-color (e.g. black on a light color). Only the neutral, un-selected
// state forces `on-surface` for readability.
if (useBgColor) {
return {};
}

return {
color: 'rgb(var(--v-theme-on-surface))',
};
};

const getLabelClass = (option: Option): object => {
const isActiveOption = isActive(option.value);
const optionVariant = getVariant(option.value);
const useBgColor = isActiveOption || optionVariant === 'flat' || optionVariant === 'elevated';
const bgColor = option?.color ?? field.value?.color;

return {
[`bg-${option?.color}`]: useBgColor,
// The field/option `class` is applied to the label itself. A
// text-transform utility set directly on the label wins over the value
// it would otherwise inherit from the button (e.g. a global `VBtn`
// `text-uppercase` default), so the app default is respected when no
// class is set but can be altered per-field/option when one is.
[`bg-${bgColor}`]: useBgColor && bgColor != null,
[`${field.value?.class}`]: field.value?.class != null,
[`${option?.class}`]: option?.class != null,
};
};

Expand All @@ -470,10 +493,4 @@ function containsSizeUnit(value: string | number): boolean {
.v-item-group {
flex-wrap: wrap;
}

.vsf-button-field {
&__btn-label {
color: v-bind(buttontextcolor);
}
}
</style>
6 changes: 6 additions & 0 deletions src/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
declare module '*.vue';

// Vuetify only exposes `vuetify/styles`' type declarations via its package
// `exports` map, which the classic `node` module resolution used by this
// project cannot read. The import is a CSS side-effect with no meaningful
// types, so declare it ambiently to satisfy the side-effect import.
declare module 'vuetify/styles';
2 changes: 0 additions & 2 deletions tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"composite": true,
"declaration": true,
"declarationDir": "./dist",
Expand Down Expand Up @@ -86,7 +85,6 @@
"src/**/__tests__/*",
"playground",
"src/playground/configs/templates/PlaygroundPage.vue",
"src/plugins/**/*.ts",
"src/stores/**/*.ts"
],
}
4 changes: 3 additions & 1 deletion tsconfig.cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"./node_modules/@types"
],
"types": [
"cypress-real-events",
"cypress",
"node",
]
},
"exclude": [],
Expand All @@ -19,6 +20,7 @@
"cypress/support/commands.ts",
"cypress/support/component.*",
"vite.cypress.config.ts",
"package.json",
"src/**/*",
"src/**/*.vue",
"src/**/__tests__/*"
Expand Down
Loading