Skip to content

Commit

Permalink
Move boolean toggle example to general examples
Browse files Browse the repository at this point in the history
Add a new example 'Boolean Toggle' that showcases checkbox vs toggle boolean rendering.
  • Loading branch information
lucas-koehler committed Feb 16, 2021
1 parent 8ac0568 commit 133538d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
THE SOFTWARE.
*/

import { registerExamples } from "./register";

export const schema = {
type: 'object',
properties: {
Expand Down Expand Up @@ -64,3 +66,5 @@ export const booleanToggleExample = {
schema,
uischema
};

registerExamples([booleanToggleExample]);
6 changes: 4 additions & 2 deletions packages/examples/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
The MIT License
Copyright (c) 2017-2019 EclipseSource Munich
Copyright (c) 2017-2021 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -69,6 +69,7 @@ import * as defaultExample from './default';
import * as onChange from './onChange';
import * as enumExample from './enum';
import * as radioGroupExample from './radioGroup';
import * as booleanToggle from './booleanToggle';
export * from './register';
export * from './example';

Expand Down Expand Up @@ -122,5 +123,6 @@ export {
ifThenElse,
onChange,
enumExample,
radioGroupExample
radioGroupExample,
booleanToggle
};
5 changes: 1 addition & 4 deletions packages/material/example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ import { materialCells } from '../src';
import { extendedMaterialRenderers } from '../src/extended';
import { ExampleExtension } from './CustomAutocomplete';
import { ReactExampleDescription } from '../../example/src/util';
import { booleanToggleExample } from './booleanToggle';

const addCustomAutocompleteControl = (examples: ReactExampleDescription[]) => {
const enhancedExamples = examples.map(example => {
return examples.map(example => {
if(example.name === 'enum'){
const adjustedExample = Object.assign({}, example, {
customReactExtension: ExampleExtension
Expand All @@ -39,8 +38,6 @@ const addCustomAutocompleteControl = (examples: ReactExampleDescription[]) => {
}
return example;
});
enhancedExamples.push(booleanToggleExample);
return enhancedExamples;
};

renderExample(
Expand Down
1 change: 0 additions & 1 deletion packages/material/src/mui-controls/MuiToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const MuiToggle = React.memo((props: CellProps & WithClassname) => {
} = props;
const appliedUiSchemaOptions = merge({}, config, uischema.options);
const inputProps = { autoFocus: !!appliedUiSchemaOptions.focus };
// !! causes undefined value to be converted to false, otherwise has no effect
const checked = !!data;

return (
Expand Down

0 comments on commit 133538d

Please sign in to comment.