From bac1e2152ac7acdef68051249f8f8f1f33cc165b Mon Sep 17 00:00:00 2001 From: Adam Kudrna Date: Wed, 27 Nov 2024 17:59:07 +0100 Subject: [PATCH] Inherit link color in components that support validation states (#492) --- src/components/CheckboxField/README.md | 40 ++++++++++++++++++--- src/components/TextField/README.md | 16 +++++++-- src/components/Toggle/README.md | 10 +++++- src/styles/theme/_form-fields.scss | 19 ++++++++++ src/styles/tools/form-fields/_variants.scss | 6 +++- webpack.config.babel.js | 2 +- 6 files changed, 83 insertions(+), 10 deletions(-) diff --git a/src/components/CheckboxField/README.md b/src/components/CheckboxField/README.md index a280694a..51594d3e 100644 --- a/src/components/CheckboxField/README.md +++ b/src/components/CheckboxField/README.md @@ -18,7 +18,13 @@ React.createElement(() => { return ( + I have read and agree with + {' '} + + + )} onChange={() => setAgree(!agree)} /> ); @@ -132,20 +138,44 @@ React.createElement(() => { <> + I have read and agree with + {' '} + + + )} onChange={() => setAgree(!agree)} validationState="valid" /> + I have read and agree with + {' '} + + + )} onChange={() => setAgree(!agree)} validationState="warning" - validationText="Please wait 10 minutes until we verify your data." + validationText={( + <> + Please wait 10 minutes until we verify your data. + {' '} + + + )} /> + I have read and agree with + {' '} + + + )} onChange={() => setAgree(!agree)} required validationState="invalid" diff --git a/src/components/TextField/README.md b/src/components/TextField/README.md index 5e31ec39..f1241a6f 100644 --- a/src/components/TextField/README.md +++ b/src/components/TextField/README.md @@ -388,7 +388,13 @@ have. label="User name" onChange={() => {}} validationState="warning" - validationText="Account with this name already exists, pick a different one." + validationText={( + <> + Account with this name already exists, pick a different one. + {' '} + + + )} value="joe" required /> @@ -411,7 +417,13 @@ have. label="User name" onChange={() => {}} validationState="warning" - validationText="Account with this name already exists, pick a different one." + validationText={( + <> + Account with this name already exists, pick a different one. + {' '} + + + )} variant="filled" value="joe" required diff --git a/src/components/Toggle/README.md b/src/components/Toggle/README.md index d84c3806..f1373746 100644 --- a/src/components/Toggle/README.md +++ b/src/components/Toggle/README.md @@ -148,7 +148,15 @@ React.createElement(() => { label="Listen in studio quality" onChange={() => setStudioQuality(!studioQuality)} validationState="invalid" - validationText="Please upgrade your plan to make this option available." + validationText={( + <> + Please + {' '} + + {' '} + to make this option available. + + )} /> ); diff --git a/src/styles/theme/_form-fields.scss b/src/styles/theme/_form-fields.scss index 7bd1ee6b..f7cd2b5b 100644 --- a/src/styles/theme/_form-fields.scss +++ b/src/styles/theme/_form-fields.scss @@ -30,6 +30,25 @@ $horizontal-label-vertical-alignment: var(--rui-FormField--horizontal__label__ve $horizontal-field-vertical-alignment: var(--rui-FormField--horizontal__field__vertical-alignment); $horizontal-full-width-label-width: var(--rui-FormField--horizontal--full-width__label__width); +// Form fields: links in validation states +$link-validation-colors: ( + invalid: ( + default: var(--rui-color-feedback-success), + hover: var(--rui-color-feedback-success-hover), + active: var(--rui-color-feedback-success-active), + ), + valid: ( + default: var(--rui-color-feedback-valid), + hover: var(--rui-color-feedback-valid-hover), + active: var(--rui-color-feedback-valid-active), + ), + warning: ( + default: var(--rui-color-feedback-warning), + hover: var(--rui-color-feedback-warning-hover), + active: var(--rui-color-feedback-warning-active), + ), +); + // Form fields: disabled state $disabled-cursor: var(--rui-FormField--disabled__cursor); $disabled-opacity: var(--rui-FormField--disabled__opacity); diff --git a/src/styles/tools/form-fields/_variants.scss b/src/styles/tools/form-fields/_variants.scss index 265843d7..d132eecb 100644 --- a/src/styles/tools/form-fields/_variants.scss +++ b/src/styles/tools/form-fields/_variants.scss @@ -70,7 +70,7 @@ + "Choose one of #{map.keys(settings.$themeable-variant-states)}."; } - $themeable-states: map.get(map.get(settings.$themeable-variant-states, $type), $variant); + $themeable-states: map.get(settings.$themeable-variant-states, $type, $variant); @if list.index($themeable-states, "hover") { @include _generate-custom-properties($type, $variant, "default"); @@ -143,5 +143,9 @@ } @mixin validation($variant) { + --rui-local-link-color: map.get(theme.$link-validation-colors, $variant, default); + --rui-local-link-color-hover: map.get(theme.$link-validation-colors, $variant, hover); + --rui-local-link-color-active: map.get(theme.$link-validation-colors, $variant, active); + @include _get-theme(validation, $variant); } diff --git a/webpack.config.babel.js b/webpack.config.babel.js index db9839b2..c9263f81 100644 --- a/webpack.config.babel.js +++ b/webpack.config.babel.js @@ -5,7 +5,7 @@ const TerserPlugin = require('terser-webpack-plugin'); const VisualizerPlugin = require('webpack-visualizer-plugin2'); const MAX_DEVELOPMENT_OUTPUT_SIZE = 3300000; -const MAX_PRODUCTION_OUTPUT_SIZE = 430000; +const MAX_PRODUCTION_OUTPUT_SIZE = 440000; module.exports = (env, argv) => ({ devtool: argv.mode === 'production'