Skip to content

Commit

Permalink
Merge branch 'master' into FE-4025-dialog-text-wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
Dawid Zarzycki committed May 13, 2021
2 parents 2c9715d + 19a0d0a commit 75ae0d6
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 119 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [73.2.0](https://github.com/Sage/carbon/compare/v73.1.0...v73.2.0) (2021-05-12)


### Features

* **button-toggle-group:** add styled-system props ([510a643](https://github.com/Sage/carbon/commit/510a64392403d0e4fa6706465478bcd3bbde21ac))

## [73.1.0](https://github.com/Sage/carbon/compare/v73.0.0...v73.1.0) (2021-05-12)


Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "carbon-react",
"version": "73.1.0",
"version": "73.2.0",
"description": "A library of reusable React components for easily building user interfaces.",
"engineStrict": true,
"engines": {
Expand Down
6 changes: 4 additions & 2 deletions src/components/accordion/accordion-group.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import Events from "../../utils/helpers/events";
import Accordion from "./accordion.component.js";
import { StyledAccordionGroup } from "./accordion.style.js";

const marginProps = filterStyledSystemMarginProps(styledSystemPropTypes);
const marginProptypes = filterStyledSystemMarginProps(
styledSystemPropTypes.space
);

const AccordionGroup = ({ children, ...rest }) => {
const refs = useRef(
Expand Down Expand Up @@ -59,7 +61,7 @@ const AccordionGroup = ({ children, ...rest }) => {
};

AccordionGroup.propTypes = {
...marginProps,
...marginProptypes,
children: (props, propName, componentName) => {
let error;
const prop = props[propName];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import React from "react";
import PropTypes from "prop-types";
import styledSystemPropTypes from "@styled-system/prop-types";

import FormField from "../../__experimental__/components/form-field";
import ButtonToggleGroupStyle from "./button-toggle-group.style";
import RadioButtonMapper from "../../__experimental__/components/radio-button/radio-button-mapper.component";
import ValidationIcon from "../validations/validation-icon.component";
import { InputGroupBehaviour } from "../../__internal__/input-behaviour";
import { filterStyledSystemMarginProps } from "../../style/utils";

const marginPropTypes = filterStyledSystemMarginProps(
styledSystemPropTypes.space
);

const BaseButtonToggleGroup = (props) => {
const {
Expand Down Expand Up @@ -57,6 +64,7 @@ const BaseButtonToggleGroup = (props) => {
};

BaseButtonToggleGroup.propTypes = {
...marginPropTypes,
/** Specifies the name prop to be applied to each button in the group */
name: PropTypes.string.isRequired,
/** Children to be rendered (ButtonToggle). */
Expand Down Expand Up @@ -99,8 +107,6 @@ BaseButtonToggleGroup.propTypes = {
onBlur: PropTypes.func,
/** The value of the Button Toggle Group */
value: PropTypes.string,
/** Margin bottom, given number will be multiplied by base spacing unit (8) */
mb: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 7]),
};

BaseButtonToggleGroup.defaultProps = {
Expand Down
26 changes: 25 additions & 1 deletion src/components/button-toggle-group/button-toggle-group.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import "jest-styled-components";
import { ThemeProvider } from "styled-components";
import guid from "../../utils/helpers/guid";
import { baseTheme, mintTheme } from "../../style/themes";
import { assertStyleMatch } from "../../__spec_helper__/test-utils";
import {
assertStyleMatch,
testStyledSystemMargin,
} from "../../__spec_helper__/test-utils";
import { StyledButtonToggleLabel } from "../button-toggle/button-toggle.style";
import StyledValidationIcon from "../validations/validation-icon.style";
import ValidationIcon from "../validations";
Expand All @@ -14,6 +17,7 @@ import Label from "../../__experimental__/components/label";
import ButtonToggleGroup from "./button-toggle-group.component";
import ButtonToggle from "../button-toggle/button-toggle.component";
import ButtonToggleGroupStyle from "./button-toggle-group.style";
import FormFieldStyle from "../../__experimental__/components/form-field/form-field.style";
import FormField from "../../__experimental__/components/form-field";

jest.mock("../../utils/helpers/guid");
Expand Down Expand Up @@ -95,6 +99,26 @@ describe("ButtonToggleGroup", () => {
});
});

testStyledSystemMargin(
(props) => (
<ButtonToggleGroup
id="button-toggle-group-id"
name="button-toggle-group"
{...props}
>
<ButtonToggle id="foo" value="foo">
Foo
</ButtonToggle>
<ButtonToggle id="bar" value="bar">
Bar
</ButtonToggle>
</ButtonToggleGroup>
),
undefined,
(component) => component.find(FormFieldStyle),
{ modifier: "&&&" }
);

describe("validations", () => {
const validationTypes = ["error", "warning", "info"];
describe.each(validationTypes)(
Expand Down
Loading

0 comments on commit 75ae0d6

Please sign in to comment.