Skip to content

Commit

Permalink
Merge branch 'develop' into feature/203_adres_component_tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
wouter-adriaens committed Jan 24, 2024
2 parents 3e3df9d + 2dc3e3e commit 4195128
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/__tests__/InputPhone.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,34 @@ describe('InputPhone', () => {
cy.mount(TestComponent);
});

it('sets default prefix classes', () => {
cy.mount(TestComponent);
cy.dataCy('prefix').should('have.class', 'vl-col--1-6 vl-col--2-6--m vl-col--3-6--xs');
});

it('sets default input field classes', () => {
cy.mount(TestComponent);
cy.dataCy('input-phone').should('have.class', 'vl-col--5-6 vl-col--4-6--m vl-col--3-6--xs');
});

it('sets configured prefix classes', () => {
cy.mount(TestComponent, {
props: {
prefixClass: 'test',
},
});
cy.dataCy('prefix').should('have.class', 'test');
});

it('sets configured input field classes', () => {
cy.mount(TestComponent, {
props: {
inputFieldClass: 'test',
},
});
cy.dataCy('input-phone').should('have.class', 'test');
});

describe('BE', () => {
it('renders a placeholder according to selected country', () => {
cy.mount(TestComponent);
Expand Down
12 changes: 10 additions & 2 deletions src/components/dumb/InputPhone.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="input-phone vl-grid" data-cy="input-phone-wrapper">
<div class="vl-col--1-6 vl-col--2-6--m vl-col--3-6--xs">
<div :class="prefixClass" data-cy="prefix">
<vl-multiselect
v-bind="$attrs"
v-model="countryCode"
Expand Down Expand Up @@ -29,7 +29,7 @@
data-cy="input-phone"
:mod-error="(phoneNumberValue && inputTouched && !phoneNumberParsed?.isValid()) || $attrs['mod-error']"
:placeholder="phoneNumberExample"
class="vl-col--5-6 vl-col--4-6--m vl-col--3-6--xs"
:class="inputFieldClass"
type="tel"
@blur="inputTouched = true"
></vl-input-field>
Expand Down Expand Up @@ -63,6 +63,14 @@ const props = withDefaults(defineProps<IInputPhoneProps>(), {
});
const emit = defineEmits(['update:modelValue']);
// Classes
const prefixClass = computed(() =>
props.prefixClass ? props.prefixClass : 'vl-col--1-6 vl-col--2-6--m vl-col--3-6--xs'
);
const inputFieldClass = computed(() =>
props.inputFieldClass ? props.inputFieldClass : 'vl-col--5-6 vl-col--4-6--m vl-col--3-6--xs'
);
// Country code
const countryCodeList = ref<ICountryCode[]>([
{ value: '+32', description: '(+32) België', code: 'BE' },
Expand Down
2 changes: 2 additions & 0 deletions src/models/input-phone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { CountryCode } from 'libphonenumber-js';
export interface IInputPhoneProps {
id: string;
modelValue: string;
prefixClass: string;
inputFieldClass: string;
}

export interface ICountryCode {
Expand Down

0 comments on commit 4195128

Please sign in to comment.