-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add theme uswds v3.0 on v6 (main) #4596
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
Conversation
# Dependency directories | ||
node_modules/ | ||
|
||
# Optional npm cache directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already in the .gitignore
on the head of main
which you are not on yet
{...otherProps} | ||
data-testid="copy-button" | ||
aria-label={translatedLabel} | ||
className={`usa-button usa-button--unstyled ${otherProps.className || ''}`.trim()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
className={`usa-button usa-button--unstyled ${otherProps.className || ''}`.trim()} | |
className={`usa-button usa-button--unstyled ${className}`.trim()} |
S extends StrictRJSFSchema = RJSFSchema, | ||
F extends FormContextType = any, | ||
>(props: IconButtonProps<T, S, F>) { | ||
const { icon, iconType, registry, ...otherProps } = props; // Destructure registry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { icon, iconType, registry, ...otherProps } = props; // Destructure registry | |
const { icon, iconType, registry, className = '', ...otherProps } = props; // Destructure registry |
const translatedLabel = registry.translateString(TranslatableString.AddItemButton); | ||
return ( | ||
// Add appropriate styling for an icon-only button if desired, e.g., usa-button--icon-only | ||
<Button type="button" {...otherProps} data-testid="add-button" aria-label={translatedLabel} className={`usa-button usa-button--outline ${otherProps.className || ''}`.trim()}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Button type="button" {...otherProps} data-testid="add-button" aria-label={translatedLabel} className={`usa-button usa-button--outline ${otherProps.className || ''}`.trim()}> | |
<Button type="button" {...otherProps} data-testid="add-button" aria-label={translatedLabel} className={`usa-button usa-button--outline ${className}`.trim()}> |
|
||
export default function DescriptionField<T = any, S extends RJSFSchema = RJSFSchema, F extends FormContextType = any>({ | ||
description, | ||
id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id, | |
id, | |
registry, | |
uiSchema, |
Still more comments to come |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JJediny I'm not going to pull any punches here. This theme is a mess. Tons of duplicated code, implementing things that aren't necessary, multiple template implementations for the same thing. It seems like you don't really understand the basic concepts of building a theme that extends the core
theme. Most theme builders look at the other non-core themes that closest represent the way their theme library works, copy that and change the templates and widgets. No need for fields to be updated at all.
I'm almost tempted to suggest you restart building your theme by copying something like the react-bootstrap
theme as the starting point and reimplement. There is a lot of cleanup work you'll need to do so that you can have this theme ready
}, | ||
}, | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert these changes?
"@babel/preset-react", | ||
"@babel/preset-typescript" | ||
] | ||
} No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The little dash surrounded by the red circle means this needs a blank line
} | |
} | |
"require": "./dist/index.js", | ||
"import": "./lib/index.js", | ||
"types": "./lib/index.d.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, the types are supposed to be first, my bad
"require": "./dist/index.js", | |
"import": "./lib/index.js", | |
"types": "./lib/index.d.ts" | |
"types": "./lib/index.d.ts", | |
"require": "./dist/index.js", | |
"import": "./lib/index.js" |
"require": "./dist/index.js", | ||
"import": "./lib/index.js", | ||
"types": "./lib/index.d.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"require": "./dist/index.js", | |
"import": "./lib/index.js", | |
"types": "./lib/index.d.ts" | |
"types": "./lib/index.d.ts", | |
"require": "./dist/index.js", | |
"import": "./lib/index.js" |
"require": "./dist/*.js", | ||
"import": "./lib/*.js", | ||
"types": "./lib/*.d.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"require": "./dist/*.js", | |
"import": "./lib/*.js", | |
"types": "./lib/*.d.ts" | |
"types": "./lib/*.d.ts", | |
"require": "./dist/*.js", | |
"import": "./lib/*.js" |
@@ -0,0 +1,19 @@ | |||
import Form from '../src'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this, please delete the whole file
@@ -0,0 +1,22 @@ | |||
import Form from '../src'; | |||
// import { createSchemaTest } from '../schemaTests'; // Removed usage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this, please delete the whole file
// Create a simple test suite to prevent "test suite must contain at least one test" error | ||
describe('ArrayField', () => { | ||
it('should have a test', () => { | ||
expect(true).toBe(true); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need this as the other themes don't complain
// Create a simple test suite to prevent "test suite must contain at least one test" error | ||
describe('Form', () => { | ||
it('should have a test', () => { | ||
expect(true).toBe(true); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need this as the other themes don't complain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a .jsc
file, use .json
instead
@JJediny I apologize if my feedback felt harsh. I'm hoping you closed this to follow my suggestion of starting fresh by modifying a copied theme rather than giving up on adding the theme entirely. Feel free to reach out on discord if you need any help |
@heath-freenome all good, yes will resume work on our fork and better formulate before another PR. This dropped on our immediate priorities. Next time I will be sure to address all the feedback and suggestions thus far and start from an established theme. Appreciate your time |
Closes #4573
Reasons for making this change
This PR introduces a new theme package,
@rjsf/uswds
, implementing the U.S. Web Design System (USWDS) v3 forreact-jsonschema-form
.Many government projects require adherence to USWDS guidelines. This theme provides developers with an RJSF implementation that uses standard USWDS components, classes, and structure, ensuring visual consistency and compliance.
Key features include:
Object
,Array
,String
,Number
,Boolean
, etc.) styled according to USWDS.usa-input
,usa-textarea
,usa-checkbox
,usa-radio
,usa-select
, etc.).fieldset
,legend
, and grid layout (grid-row
,grid-col
).Add
,Remove
,Move Up
,Move Down
) using USWDS button styles (usa-button
,usa-button--outline
,usa-button--unstyled
) and icons loaded from the official USWDS CDN.usa-form-group--error
,usa-label--error
,usa-error-message
).usa-label--required
.Checklist
packages/uswds/README.md
)npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update
to update snapshots, if needed. (Self-verification step)feat(@rjsf/uswds): Add new theme package for US Web Design System v3
)