Skip to content

Commit

Permalink
fix(textfield/textarea): clean up classes (#163)
Browse files Browse the repository at this point in the history
* refactor(textfield): update component classes

* refactor(textarea): update component classes

* chore(deps): update @warp-ds/uno to 1.12.0 and @warp-ds/css to 1.9.6

* chore(workflows): use pnpm v9 in github actions
  • Loading branch information
BalbinaK committed May 14, 2024
1 parent 9ad7871 commit 2babe15
Show file tree
Hide file tree
Showing 8 changed files with 9,224 additions and 7,580 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install pnpm and dependencies
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: true
- name: Validate extracted messages
run: pnpm messages:compile
2 changes: 1 addition & 1 deletion .github/workflows/lint.pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install pnpm and dependencies
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: true
- name: Lint
run: pnpm lint:check
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install pnpm and dependencies
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: true
- name: Build
run: pnpm build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install pnpm and dependencies
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: true
- name: Test
run: pnpm test
25 changes: 9 additions & 16 deletions components/forms/w-textarea.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<template>
<w-field v-bind="{ ...$attrs, ...$props }" #default="{ triggerValidation, aria, hasValidationErrors }">
<div :class="wrapperClass">
<div :class="[ccInput.wrapper]">
<textarea
:class="[
inputClasses,
{
[ccInput.invalid]: hasValidationErrors,
}
]"
:class="{
[`${ccInput.base} ${ccInput.textArea}`]: true,
[ccInput.placeholder]: !!p.placeholder,
[ccInput.default]: !hasValidationErrors && !p.disabled && !p.readOnly,
[ccInput.invalid]: hasValidationErrors && !p.disabled && !p.readOnly,
[ccInput.disabled]: !hasValidationErrors && p.disabled && !p.readOnly,
[ccInput.readOnly]: !hasValidationErrors && !p.disabled && p.readOnly,
}"
:disabled="disabled"
:readOnly="readOnly"
v-bind="{ ...aria, ...$attrs, class: '' }" v-model="model" :id="id" @blur="triggerValidation"
Expand All @@ -17,22 +19,13 @@
</template>

<script setup>
import { computed } from 'vue';
import { input as ccInput } from '@warp-ds/css/component-classes';
import { createModel } from 'create-v-model';
import { default as wField, fieldProps } from './w-field.vue';
const p = defineProps(fieldProps);
const emit = defineEmits(['update:modelValue']);
const model = createModel({ props: p, emit });
const wrapperClass = ccInput.wrapper;
const inputClasses = computed(() => ({
[`${ccInput.default} ${ccInput.textArea}`]: true,
[ccInput.disabled]: p.disabled,
[ccInput.readOnly]: p.readOnly,
[ccInput.placeholder]: !!p.placeholder,
}));
</script>

<script>
Expand Down
46 changes: 21 additions & 25 deletions components/forms/w-textfield.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { ref, computed, useSlots } from 'vue';
import { ref, useSlots } from 'vue';
import { input as ccInput } from '@warp-ds/css/component-classes';
import { createModel } from 'create-v-model';
import { setupMask } from './w-input-mask.js';
Expand All @@ -24,18 +24,7 @@ const slots = useSlots();
const model = createModel({ props: p, emit });
const inputEl = ref(null);
if (p.mask) setupMask({ props: p, emit, inputEl });
const inputClasses = computed(() => ({
[ccInput.default]: true,
[ccInput.disabled]: p.disabled,
[ccInput.readOnly]: p.readOnly,
[ccInput.placeholder]: !!p.placeholder,
[ccInput.suffix]: slots.suffix,
[ccInput.prefix]: slots.prefix,
}));
const inputWithPrefixStyle = computed(() => (
slots.prefix ? 'padding-left: var(--w-prefix-width, 40px);' : undefined
))
</script>

<template>
Expand All @@ -47,12 +36,16 @@ const inputWithPrefixStyle = computed(() => (
:id="id"
ref="inputEl"
:type="type"
:class="[
inputClasses,
{
[ccInput.invalid]: hasValidationErrors,
}
]"
:class="{
[ccInput.base]: true,
[ccInput.default]: !hasValidationErrors && !p.disabled && !p.readOnly,
[ccInput.invalid]: hasValidationErrors && !p.disabled && !p.readOnly,
[ccInput.disabled]: !hasValidationErrors && p.disabled && !p.readOnly,
[ccInput.readOnly]: !hasValidationErrors && !p.disabled && p.readOnly,
[ccInput.placeholder]: !!p.placeholder,
[ccInput.suffix]: slots.suffix,
[ccInput.prefix]: slots.prefix
}"
:autocomplete="autocomplete"
:disabled="disabled"
:placeholder="placeholder"
Expand All @@ -65,19 +58,22 @@ const inputWithPrefixStyle = computed(() => (
ref="inputEl"
v-model="model"
:type="type"
:class="[
inputClasses,
{
[ccInput.invalid]: hasValidationErrors,
}
]"
:class="{
[ccInput.base]: true,
[ccInput.default]: !hasValidationErrors && !p.disabled && !p.readOnly,
[ccInput.invalid]: hasValidationErrors && !p.disabled && !p.readOnly,
[ccInput.disabled]: !hasValidationErrors && p.disabled && !p.readOnly,
[ccInput.readOnly]: !hasValidationErrors && !p.disabled && p.readOnly,
[ccInput.placeholder]: !!p.placeholder,
[ccInput.suffix]: slots.suffix,
[ccInput.prefix]: slots.prefix
}"
:autocomplete="autocomplete"
:disabled="disabled"
:placeholder="placeholder"
:readOnly="readOnly"
v-bind="{ ...aria, ...$attrs, class: '' }"
@blur="triggerValidation"
:style="inputWithPrefixStyle"
>
<slot name="suffix" :inputElement="inputEl" />
</div>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
"dependencies": {
"@lingui/core": "^4.7.0",
"@warp-ds/core": "^1.1.1",
"@warp-ds/css": "1.9.3",
"@warp-ds/css": "1.9.6",
"@warp-ds/icons": "2.0.0",
"@warp-ds/uno": "1.10.2",
"@warp-ds/uno": "1.12.0",
"create-v-model": "^2.2.0",
"dom-focus-lock": "^1.1.0",
"element-collapse": "^1.1.0",
Expand Down
Loading

0 comments on commit 2babe15

Please sign in to comment.