-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 preference to switch between AA & AAA levels for color-contrast checks #41363
base: trunk
Are you sure you want to change the base?
Changes from all commits
a1493c8
6ca8c9b
6c420b1
8c9f361
edf28c5
b4b5538
8e24ba2
2fc63ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* WordPress dependencies | ||
*/ | ||
|
||
import { __ } from '@wordpress/i18n'; | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
import { useViewportMatch } from '@wordpress/compose'; | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import { useMemo } from '@wordpress/element'; | ||
|
@@ -76,6 +76,10 @@ export default function EditPostPreferencesModal() { | |
closeGeneralSidebar(); | ||
}; | ||
|
||
const colorContrastCheckAAA = useSelect( ( select ) => { | ||
const { isFeatureActive } = select( editPostStore ); | ||
return isFeatureActive( 'strictColorContrastChecks' ); | ||
}, [] ); | ||
Comment on lines
+79
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be selected from the preferences store instead of using |
||
const sections = useMemo( | ||
() => [ | ||
{ | ||
|
@@ -152,6 +156,14 @@ export default function EditPostPreferencesModal() { | |
label={ __( 'Display block breadcrumbs' ) } | ||
/> | ||
) } | ||
<EnableFeature | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mentioned in another issue that it'd make sense to introduce a new Accessibility panel to the settings modal instead of folding everything into appearance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here: #41041 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this something that would block this PR? I believe that if at some point we introduce an a11y panel, then we can move that option there (if and when that happens) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't block this, just connecting the dots since it's been mentioned in a few PRs adding features but hasn't gotten much attention. |
||
featureName="strictColorContrastChecks" | ||
help={ sprintf( | ||
'Switches the color contrast checker to be comply with WCAG AAA guidelines instead of WCAG AA. Currently checking for: %s.', | ||
colorContrastCheckAAA ? 'AAA' : 'AA' | ||
) } | ||
label={ __( 'Strict color-contrast checker' ) } | ||
/> | ||
</PreferencesModalSection> | ||
</> | ||
), | ||
|
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.
When preferences are saved they're grouped into objects like this:
So you'd need to decide what the right value here should be. A problem is that this is in the 'block-editor' package which is used across both the post and site editor, so having 'core/edit-post' hardcoded doesn't seem like the right option.
I think it would be good to have the
strictContrastCheck
passed in as a prop to the component rather than have the preference built-in to solve that. You'd then have more control over whether to use 'core', 'core/edit-post' or 'core/edit-site' as the place to save the preference value.