Skip to content

Commit

Permalink
vue-vanilla: Add configurable style class to OneOfRenderer (#2272)
Browse files Browse the repository at this point in the history
  • Loading branch information
davewwww authored Feb 8, 2024
1 parent e06f5e8 commit 5c6806f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vue-vanilla/src/complex/OneOfRenderer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div v-if="control.visible">
<div v-if="control.visible" :class="styles.oneOf.root">
<combinator-properties
:schema="control.schema"
combinator-keyword="oneOf"
Expand Down
3 changes: 3 additions & 0 deletions packages/vue-vanilla/src/styles/defaultStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ export const defaultStyles: Styles = {
buttonPrimary: 'dialog-button-primary',
buttonSecondary: 'dialog-button-secondary',
},
oneOf: {
root: 'one-of',
},
};
4 changes: 4 additions & 0 deletions packages/vue-vanilla/src/styles/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const createEmptyStyles = (): Styles => ({
arrayList: {},
label: {},
dialog: {},
oneOf: {},
});

export interface Styles {
Expand Down Expand Up @@ -65,6 +66,9 @@ export interface Styles {
label: {
root?: string;
};
oneOf: {
root?: string;
};
}

export const useStyles = (element?: UISchemaElement) => {
Expand Down
5 changes: 5 additions & 0 deletions packages/vue-vanilla/tests/unit/complex/OneOfRenderer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const uischema = {
};

describe('OneOfRenderer.vue', () => {
it('render has a class', () => {
const wrapper = mountJsonForms({ variant: 'b', b: 'b' }, schema, uischema);
expect(wrapper.find('div.one-of').exists()).to.be.true;
});

it('renders select label', () => {
const wrapper = mountJsonForms({ variant: 'b', b: 'b' }, schema, uischema);
expect(wrapper.find('label').text()).to.equal('My Object');
Expand Down

0 comments on commit 5c6806f

Please sign in to comment.