Skip to content

Commit

Permalink
Merge pull request #554 from catho/QTM-645
Browse files Browse the repository at this point in the history
fix(QTM-645): Nested syntax handling to maintain compatibility with styled components v6
  • Loading branch information
MarcosViniciusPC authored Apr 3, 2024
2 parents 3da9ea8 + a2e897d commit 6014d08
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 58 deletions.
2 changes: 1 addition & 1 deletion components/Alert/Alert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const CloseButton = styled(Button.Icon).attrs({
transition: opacity 0.4s ease;
width: auto;
:hover {
&:hover {
background: none;
opacity: 1;
}
Expand Down
16 changes: 9 additions & 7 deletions components/Button/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ const StyledButton = styled.button`
color: ${textColor};
border: 2px solid ${borderColor};
${shadow(2, neutral500)({ theme })} :hover {
${shadow(2, neutral500)({ theme })}
&:hover {
${!disabled
? css`
${shadow(4, mainColor900)({ theme })}
Expand All @@ -178,12 +180,12 @@ const StyledButton = styled.button`
: ''}
}
:focus,
:focus-within {
&:focus,
&:focus-within {
${!disabled ? shadow(4, mainColor700)({ theme }) : ''}
}
:active {
&:active {
${!disabled
? css`
${shadow(8, mainColor900)({ theme })}
Expand Down Expand Up @@ -301,14 +303,14 @@ const IconButton = styled(Button)`
margin-right: 0;
}
:hover,
:focus {
&:hover,
&:focus {
box-shadow: none;
background-color: ${hexToRgba(mainColor300, 0.4)};
color: ${mainColor700};
}
:active {
&:active {
box-shadow: none;
background-color: ${hexToRgba(mainColor300, 0.5)};
color: ${mainColor700};
Expand Down
14 changes: 7 additions & 7 deletions components/Checkbox/Checkbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Wrapper = styled.div`
margin-right: 16px;
vertical-align: top;
:last-child {
&:last-child {
margin-right: 0;
}
`}
Expand Down Expand Up @@ -94,7 +94,7 @@ const HiddenCheckbox = styled(HiddenInput).attrs({
`}
}
:checked {
&:checked {
+ ${CheckIcon} {
border-width: 0;
Expand All @@ -112,7 +112,7 @@ const HiddenCheckbox = styled(HiddenInput).attrs({
}
}
:hover + ${CheckIcon}, :focus + ${CheckIcon} {
&:hover + ${CheckIcon}, &:focus + ${CheckIcon} {
${({ theme }) => {
const {
colors: {
Expand Down Expand Up @@ -141,11 +141,11 @@ const HiddenCheckbox = styled(HiddenInput).attrs({
border-color: ${errorColor};
}
:checked + ${CheckIcon} {
&:checked + ${CheckIcon} {
background-color: ${errorColor};
}
:hover + ${CheckIcon}, :focus + ${CheckIcon} {
&:hover + ${CheckIcon}, &:focus + ${CheckIcon} {
border-color: ${errorColor};
${shadow(5, errorColor)({ theme })}
}
Expand All @@ -172,12 +172,12 @@ const HiddenCheckbox = styled(HiddenInput).attrs({
background-color: ${neutral300};
}
:checked + ${CheckIcon} {
&:checked + ${CheckIcon} {
background-color: ${neutral500};
}
`}
:hover + ${CheckIcon} {
&:hover + ${CheckIcon} {
${shadow()}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/Checkbox/CheckboxButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const Wrapper = styled.div`
margin-right: 16px;
vertical-align: top;
:last-child {
&:last-child {
margin-right: 0;
}
`}
Expand Down
8 changes: 4 additions & 4 deletions components/DropdownLight/DropdownLight.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,23 @@ const Button = styled.button`
: colors.neutral['0']};
border: 2px solid ${error ? colors.error['700'] : colors.neutral['500']};
:disabled {
&:disabled {
background-color: ${colors.neutral['100']};
border-color: ${colors.neutral['500']};
color: ${colors.neutral['500']};
box-shadow: none;
cursor: not-allowed;
}
:hover :enabled {
&:hover:enabled {
border-color: ${colors.primary['700']};
box-shadow:
0px 3px 1px -2px rgb(18 80 196 / 20%),
0px 2px 2px 0px rgb(18 80 196 / 14%),
0px 1px 5px 0px rgb(18 80 196 / 12%);
}
:focus :enabled {
&:focus:enabled {
border-color: ${colors.primary['700']};
box-shadow:
0px 3px 1px -2px rgb(18 80 196 / 20%),
Expand Down Expand Up @@ -151,7 +151,7 @@ const SelectionListItem = styled.li`
font-size: ${baseFontSize * 0.875}px;
padding: ${spacing.xsmall}px ${spacing.medium}px;
:hover {
&:hover {
background-color: ${colors.neutral['100']};
}
`;
Expand Down
6 changes: 3 additions & 3 deletions components/Input/sub-components/TextInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const defaultSkin = ({ theme, error, hasDefaultValue }) => {
${error ? `border-color: ${mainColor};` : ''}
${hasDefaultValue ? `background-color: ${primary100};` : ''}
:hover, :focus {
&:hover, &:focus {
border-color: ${mainColor};
${shadow(2, mainColor)({ theme })}
}
Expand Down Expand Up @@ -63,8 +63,8 @@ const darkSkin = ({ theme, error }) => {
border-color: ${neutral[0]};
`
: ''}
:hover,
:focus {
&:hover, &:focus {
border-color: ${primary[500]};
}
Expand Down
4 changes: 2 additions & 2 deletions components/Pagination/sub-components/ActionButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const ActionButton = styled.a`
}
&[aria-disabled=false] {
:hover,
:focus {
&:hover,
&:focus {
background-color: ${primary100};
border: 2px solid ${primary700};
}
Expand Down
2 changes: 1 addition & 1 deletion components/Pagination/sub-components/Mobile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const StyledActionButton = styled(ActionButton)`
}
&[aria-disabled=false] {
:focus {
&:focus {
border-width: 1px;
}
}
Expand Down
3 changes: 1 addition & 2 deletions components/Pagination/sub-components/PageButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ const PageButton = styled.a`
margin: 0 ${xxsmall}px;
padding: ${xxsmall}px ${xsmall}px;
:hover,
:focus {
&:hover, &:focus {
background-color: ${active ? primary900 : primary100};
border-color: ${active ? primary900 : primary700};
color: ${active ? neutral0 : primary700};
Expand Down
2 changes: 1 addition & 1 deletion components/Popover/sub-components/Content.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const CloseButton = styled(Button.Icon).attrs({
transition: opacity 0.4s ease;
width: auto;
:hover {
&:hover {
background: none;
opacity: 1;
${_getTextColor}
Expand Down
35 changes: 17 additions & 18 deletions components/RadioGroup/Radio.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const RadioMark = styled.span`
border: 2px solid ${gray};
margin-right: ${xsmall}px;
`}
:after {
&:after {
border-radius: 50%;
content: '';
display: none;
Expand All @@ -53,7 +53,7 @@ const RadioLabel = styled(Label)`
user-select: none;
${HiddenInput} {
:checked {
&:checked {
~ ${RadioMark} {
${({
theme: {
Expand All @@ -63,15 +63,15 @@ const RadioLabel = styled(Label)`
},
}) => `
border-color: ${primary};
:after {
&:after {
background-color: ${primary};
display: block;
}
`}
}
}
:focus {
&:focus {
~ ${RadioMark} {
${({ theme }) => {
const {
Expand All @@ -89,8 +89,8 @@ const RadioLabel = styled(Label)`
}
}
:hover,
:focus {
&:hover,
&:focus {
${RadioMark} {
${({ theme }) => {
const {
Expand Down Expand Up @@ -118,16 +118,16 @@ const RadioLabel = styled(Label)`
error &&
`
${HiddenInput} {
:checked {
&:checked {
~ ${RadioMark} {
border-color: ${errorColor};
:after {
&:after {
background-color: ${errorColor};
display: block;
}
}
}
:focus {
&:focus {
~ ${RadioMark} {
border-color: ${errorColor};
${shadow(5, errorColor)({ theme })}
Expand All @@ -139,8 +139,7 @@ const RadioLabel = styled(Label)`
border-color: ${errorColor};
}
:hover,
:focus {
&:hover, &:focus {
${RadioMark} {
border-color: ${errorColor};
${shadow(5, errorColor)({ theme })}
Expand All @@ -163,44 +162,44 @@ const RadioLabel = styled(Label)`
`
color: ${neutral500};
:hover {
&:hover {
cursor: not-allowed;
}
${HiddenInput} {
:disabled {
&:disabled {
~ ${RadioMark} {
background-color: ${neutral300};
}
}
:checked {
&:checked {
~ ${RadioMark} {
border-color: ${errorColor};
:after {
&:after {
background-color: ${errorColor};
display: block;
}
}
}
:checked:disabled {
&:checked:disabled {
background-color: ${neutral500};
border-color: ${neutral500};
~ ${RadioMark}:after {
background-color: ${neutral500};
}
}
:focus {
&:focus {
~ ${RadioMark} {
border-color: ${neutral500};
box-shadow: none;
}
}
}
:hover, :focus {
&:hover, &:focus {
${RadioMark} {
border-color: ${neutral500};
box-shadow: none;
Expand Down
2 changes: 1 addition & 1 deletion components/RadioGroup/RadioButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const Wrapper = styled.div`
margin-right: ${medium}px;
vertical-align: top;
:last-child {
&:last-child {
margin-right: 0;
}
Expand Down
12 changes: 6 additions & 6 deletions components/SnackBar/SnackBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const SnackBarDialog = styled.div`
`;
}}
:focus {
&:focus {
${a11yFocusTab}
}
`;
Expand All @@ -101,7 +101,7 @@ const TextContainer = styled.span`
margin: 0;
}
:focus {
&:focus {
${a11yFocusTab}
}
`;
Expand Down Expand Up @@ -139,8 +139,8 @@ const CloseButton = styled(Button.Icon).attrs({
margin-left: ${small}px;
color: ${text};
:hover,
:focus {
&:hover,
&:focus {
background: transparent;
box-shadow: none;
color: ${text};
Expand Down Expand Up @@ -170,8 +170,8 @@ const ActionButton = styled(Button)`
border-width: 0;
border-color: unset;
:hover,
:focus {
&:hover,
&:focus {
background: ${hexToRgba(color, 0.15)};
box-shadow: none;
color: ${color};
Expand Down
Loading

0 comments on commit 6014d08

Please sign in to comment.