Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ #19 - Basic Form.io conditionals. #28

Merged
merged 5 commits into from
May 11, 2023

Conversation

svenvandescheur
Copy link
Collaborator

@svenvandescheur svenvandescheur commented Apr 28, 2023

Closes #19

src/components/columns/columns.component.tsx Show resolved Hide resolved
src/lib/renderer/renderer.tsx Outdated Show resolved Hide resolved
src/lib/renderer/renderer.tsx Outdated Show resolved Hide resolved
src/lib/renderer/renderer.tsx Outdated Show resolved Hide resolved
src/fixtures/formio/formio-conditional.ts Outdated Show resolved Hide resolved
src/components/columns/columns.component.tsx Show resolved Hide resolved
src/fixtures/formio/formio-conditional.ts Outdated Show resolved Hide resolved
src/lib/renderer/renderer.stories.tsx Outdated Show resolved Hide resolved
export interface IRenderComponentProps {
component: IColumnComponent | IRendererComponent;
component: IRenderable;
form: IFormioForm;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it wouldn't make more sense to provide the entire form via RenderContext = React.createContext({form: {}})

It's something that will affect other aspects (I think) so it has more of a "global" and implicit nature. It would also avoid prop-drilling through utility components and have to be provided only once in the RenderForm, while we could add a storybook decorator to wrap atomic components with 🤔

Mostly thinking out loud here!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I really don't like context for that global nature. Pretty much only for application state and only if props passing and composition seem to be unpractical IMO.

Especially in the domain where we don't want to rely on internals due to the use case it's also an issue when stuff is available only in context and not through the proper interfaces.

src/lib/renderer/renderer.tsx Show resolved Hide resolved
src/lib/renderer/renderer.tsx Show resolved Hide resolved
Comment on lines +39 to +41
components?: IRenderable[];
clearOnHide?: boolean;
columns?: IRenderable[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically more correct would be (typescript code untested, so probably has some mistakes):

interface Columns {
  type: 'columns',
  columns: IRenderable[];  // or even a specific Column type...
}

type ComponentContainer = ComponentSchema & {
  type: 'fieldset' | 'editgrid'; // I think that's all we support at the moment
  components: IRenderable[];
}

type IRenderable = ComponentSchema | ComponentContainer  | Columns;

The union here is especially powerful for implementation/decision branches that you can isolate.

Copy link
Collaborator Author

@svenvandescheur svenvandescheur May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm already planning on refactoring this further in #43 due to needing to implement stuff which is renderable but not explcitly derived from the schema as a component, this is still a moving thing.

- Move fixture to story.
- Remove selector option in test.
@svenvandescheur svenvandescheur merged commit 86e9584 into main May 11, 2023
@svenvandescheur svenvandescheur deleted the feature/#19-conditionals branch May 11, 2023 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement conditionals
2 participants