Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<Checkbox> refactoring and STCOM-529 (vertical label) (#974)
* Added 'vertical'-prop for Checkbox which makes it possible to render the label above the checkbox. This change required both structural and style changes. While making the changes I did some minor refactoring and cleaned up the CSS a bit. Updated FilterGroups to match the changes for Checkbox. Added label margin as a variable because I needed to reference it within the Checkbox-component. Also updated Checkbox examples to display a vertical example. * Only apply the 'for'-prop on the root <label>-element if a 'label'-prop is present. This allows for a checkbox to be rendered inline without a label which makes it possible to render an external label-element and link the two using the 'for'-attribute on the label with the ID of the checkbox. This ensures that there's no double for-attributes which can confuse screen readers. Also added an example for this in Storybook. * Added readme (WIP) * Minor readme changes, fixed basic usage example and more clean up and refactoring of the <Checkbox>-component * Removed obsolete 'labelStyle'-prop * Removed obsolete 'hover'-prop * Removed obsolete prop 'marginBottom0' * Fixed Checkbox tests * Added inputRef-prop for Checkbox with a corresponding test. * Updated storybook example * Warning/error messages were rendered next to the checkbox/label which looked odd in tight spaced UI's. Instead, I changed the feedback messages to be rendered below the checkbox/label like other form elements. * Further Storybook examples cleanup. Removed some unnecessary logic that could make the exmaples more confusing * Removed .only from tests * Updated warning color because it's contrast ratio with a white background was insufficient according to WCAG standards. * Minor linting fix and removed name from checkboxes in storybook example * Updated readme * Setting checkbox as 'inline' if there's no label. * Updated sr-only helper class after experiencing a weird bug in the stripes-platform when clicking a checkbox * Renamed some class names, added 'innerClass'-prop which is needed to properly style the FilterGroups component checkboxes and updated the readme * Fixed tests * Simplified feedback rendering logic * Updated readme * Added additional tests * Only render a <label> if there's a label to show. Changed poitioning of the input element so that it's on top of the custom checkbox but hidden with opacity: 0; With this change we no longer have any accessibility issues with double label's if a developer uses a checkbox with an external <label> * Utilized the 'tagName'-prop on the <Label>-component instead of setting a conditional on a separate Element constant. * Fixed tests and added additional tests. Test coverage is now 100% 🎉 * Removed .only from tests and added 'storybook-static' to eslintignore (it was causing linting to run very slowly and potentially never finish)
- Loading branch information