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

✨ Add support for a custom style in uiSchema #1256

Closed

Conversation

justtonytone
Copy link

@justtonytone justtonytone commented Apr 16, 2019

Reasons for making this change

More flexibility to use inline styles. Handles #1200

If this is related to existing tickets, include links to them as well.

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • I've run npm run cs-format on my branch to conform my code to prettier coding style
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@epicfaace
Copy link
Member

Looks good! Can we make style an attribute under ui:options? That way, this change won't impact schemas that already have properties named "style".

@justtonytone
Copy link
Author

@epicfaace, that is a good point. I wanted to keep it under uiSchema to keep it consistent with classNames.

Just wanted to make sure I understood your concern. When you say schemas that already have properties named style, do you mean under the properties key? Or do you mean under the uiSchema key?

@epicfaace
Copy link
Member

@justtonytone Both. If a schema has a property named style under properties, then its corresponding uiSchema entry will have a property named style under uiSchema.

I think it's unfortunate how classNames was designed, but at least it's been around for a while and so schema creators know not to call a field with key "classNames". At this point, though, adding a styles attribute that is not under ui:options could break existing schemas that already have the property style in them. See #1248 for more problems with namespacing.

@epicfaace
Copy link
Member

epicfaace commented Jul 9, 2019

@justtonytone I'd be glad to merge this PR if you are able to change it so that the style attribute is accepted as follows:

"ui:options": {
    "style": {...}
}

@jaxomlotus
Copy link

hi @epicfaace do you have an eta on when this feature might be included? thanks!

heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this pull request Jan 15, 2023
Fixes rjsf-team#1200 by reimplementing rjsf-team#1256
- In `@rjsf/utils`, added the new `styles` prop onto `FieldTemplateProps`, `WrapIfAdditionalTemplateProps` and `UIOptionsBaseType`
- In `@rjsf/core`, added support for the new `styles` prop in `uiSchema` as follows:
  - Updated `SchemaField` to handle the new `styles` prop in the `uiSchema` similarly to `classNames`, passing it to the `FieldTemplate` and removing it from being passed down to children.
  - Also, added support for new `styles` prop on `FieldTemplate` and `WrapIfAdditionalTemplate` rendering them on the outermost wrapper
  - Added or updated tests to verify the `styles` prop functionality
- In all the themes, added support for new `styles` prop on `FieldTemplate` and `WrapIfAdditionalTemplate` rendering them on the outermost wrapper
  - Fluent-ui is a special case since it doesn't currently implement `WrapIfAdditionalTemplate` fully
- Updated the documentation to describe this new `styles` prop
  - Also updated the `validation` documentation to describe the `uiSchema` prop that can be passed to the `customValidate()` and `transformError()` functions
- Updated the `CHANGELOG.md` accordingly
@heath-freenome
Copy link
Member

Reimplemented in #3378

heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this pull request Jan 15, 2023
Fixes rjsf-team#1200 by reimplementing rjsf-team#1256
- In `@rjsf/utils`, added the new `style` prop onto `FieldTemplateProps`, `WrapIfAdditionalTemplateProps` and `UIOptionsBaseType`
- In `@rjsf/core`, added support for the new `style` prop in `uiSchema` as follows:
  - Updated `SchemaField` to handle the new `style` prop in the `uiSchema` similarly to `classNames`, passing it to the `FieldTemplate` and removing it from being passed down to children.
  - Also, added support for new `style` prop on `FieldTemplate` and `WrapIfAdditionalTemplate` rendering them on the outermost wrapper
  - Added or updated tests to verify the `style` prop functionality
- In all the themes, added support for new `style` prop on `FieldTemplate` and `WrapIfAdditionalTemplate` rendering them on the outermost wrapper
  - Fluent-ui is a special case since it doesn't currently implement `WrapIfAdditionalTemplate` fully
- Updated the documentation to describe this new `style` prop
  - Also updated the `validation` documentation to describe the `uiSchema` prop that can be passed to the `customValidate()` and `transformError()` functions
- Updated the `CHANGELOG.md` accordingly
heath-freenome added a commit that referenced this pull request Jan 15, 2023
…3378)

* fix: Add support for custom styles in a manner similar to classNames
Fixes #1200 by reimplementing #1256
- In `@rjsf/utils`, added the new `style` prop onto `FieldTemplateProps`, `WrapIfAdditionalTemplateProps` and `UIOptionsBaseType`
- In `@rjsf/core`, added support for the new `style` prop in `uiSchema` as follows:
  - Updated `SchemaField` to handle the new `style` prop in the `uiSchema` similarly to `classNames`, passing it to the `FieldTemplate` and removing it from being passed down to children.
  - Also, added support for new `style` prop on `FieldTemplate` and `WrapIfAdditionalTemplate` rendering them on the outermost wrapper
  - Added or updated tests to verify the `style` prop functionality
- In all the themes, added support for new `style` prop on `FieldTemplate` and `WrapIfAdditionalTemplate` rendering them on the outermost wrapper
  - Fluent-ui is a special case since it doesn't currently implement `WrapIfAdditionalTemplate` fully
- Updated the documentation to describe this new `style` prop
  - Also updated the `validation` documentation to describe the `uiSchema` prop that can be passed to the `customValidate()` and `transformError()` functions
- Updated the `CHANGELOG.md` accordingly

* - Renamed `styles` to `style`

* Apply suggestions from code review

Co-authored-by: Nick Grosenbacher <nickgrosenbacher@gmail.com>

Co-authored-by: Nick Grosenbacher <nickgrosenbacher@gmail.com>
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this pull request Jun 8, 2023
…jsf-team#3378)

* fix: Add support for custom styles in a manner similar to classNames
Fixes rjsf-team#1200 by reimplementing rjsf-team#1256
- In `@rjsf/utils`, added the new `style` prop onto `FieldTemplateProps`, `WrapIfAdditionalTemplateProps` and `UIOptionsBaseType`
- In `@rjsf/core`, added support for the new `style` prop in `uiSchema` as follows:
  - Updated `SchemaField` to handle the new `style` prop in the `uiSchema` similarly to `classNames`, passing it to the `FieldTemplate` and removing it from being passed down to children.
  - Also, added support for new `style` prop on `FieldTemplate` and `WrapIfAdditionalTemplate` rendering them on the outermost wrapper
  - Added or updated tests to verify the `style` prop functionality
- In all the themes, added support for new `style` prop on `FieldTemplate` and `WrapIfAdditionalTemplate` rendering them on the outermost wrapper
  - Fluent-ui is a special case since it doesn't currently implement `WrapIfAdditionalTemplate` fully
- Updated the documentation to describe this new `style` prop
  - Also updated the `validation` documentation to describe the `uiSchema` prop that can be passed to the `customValidate()` and `transformError()` functions
- Updated the `CHANGELOG.md` accordingly

* - Renamed `styles` to `style`

* Apply suggestions from code review

Co-authored-by: Nick Grosenbacher <nickgrosenbacher@gmail.com>

Co-authored-by: Nick Grosenbacher <nickgrosenbacher@gmail.com>
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this pull request Jun 8, 2023
…jsf-team#3378)

* fix: Add support for custom styles in a manner similar to classNames
Fixes rjsf-team#1200 by reimplementing rjsf-team#1256
- In `@rjsf/utils`, added the new `style` prop onto `FieldTemplateProps`, `WrapIfAdditionalTemplateProps` and `UIOptionsBaseType`
- In `@rjsf/core`, added support for the new `style` prop in `uiSchema` as follows:
  - Updated `SchemaField` to handle the new `style` prop in the `uiSchema` similarly to `classNames`, passing it to the `FieldTemplate` and removing it from being passed down to children.
  - Also, added support for new `style` prop on `FieldTemplate` and `WrapIfAdditionalTemplate` rendering them on the outermost wrapper
  - Added or updated tests to verify the `style` prop functionality
- In all the themes, added support for new `style` prop on `FieldTemplate` and `WrapIfAdditionalTemplate` rendering them on the outermost wrapper
  - Fluent-ui is a special case since it doesn't currently implement `WrapIfAdditionalTemplate` fully
- Updated the documentation to describe this new `style` prop
  - Also updated the `validation` documentation to describe the `uiSchema` prop that can be passed to the `customValidate()` and `transformError()` functions
- Updated the `CHANGELOG.md` accordingly

* - Renamed `styles` to `style`

* Apply suggestions from code review

Co-authored-by: Nick Grosenbacher <nickgrosenbacher@gmail.com>

Co-authored-by: Nick Grosenbacher <nickgrosenbacher@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants