Skip to content

Commit

Permalink
fix(react-icons): fix regression issue by adding missing `vertical-al…
Browse files Browse the repository at this point in the history
…ign: middle` style property to `SVGIcon` component (#874)

* fix(react-icons): fix regression issue by adding missing `vertical-align: middle` style property to `SVGIcon` component

* test(react): update test snapshots

* docs(playground): add `useCallback` to address `react-hooks/exhaustive-deps` issue in the Othello game

* feat(react/search-input): add `display: flex` and `alignItems: center` CSS properties to vertically align SVG icons

* test(react): update test snapshots
  • Loading branch information
cheton authored Jun 12, 2024
1 parent 4d3e26a commit 6a301aa
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import { search } from './computer';
const Othello = () => {
const [turn, setTurn] = useState(BLACK_PIECE);
const [cells, updateCells] = useState((new Array(BOARD_SIZE**2)).fill(EMPTY_PIECE));
const nextTurn = () => setTurn(turn === WHITE_PIECE ? BLACK_PIECE : WHITE_PIECE);
const nextTurn = useCallback(() => {
setTurn(turn === WHITE_PIECE ? BLACK_PIECE : WHITE_PIECE);
}, [turn]);
const restart = useCallback(() => {
const nextCells = (new Array(BOARD_SIZE**2)).fill(EMPTY_PIECE);
nextCells[BOARD_SIZE * 3 + 3] = WHITE_PIECE;
Expand Down
1 change: 1 addition & 0 deletions packages/react-icons/src/SVGIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const SVGIcon = forwardRef((
flexShrink: 0,
width: size,
height: size,
verticalAlign: 'middle',
};
const more = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ exports[`Badge should render correctly 1`] = `
flex-shrink: 0;
width: var(--tonic-sizes-4x);
height: var(--tonic-sizes-4x);
vertical-align: middle;
}
.emotion-10 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ input[type="checkbox"]:checked:disabled+.emotion-4 {
flex-shrink: 0;
width: .75rem;
height: .75rem;
vertical-align: middle;
}
.emotion-8 {
Expand Down Expand Up @@ -237,6 +238,7 @@ input[type="checkbox"]:checked:disabled+.emotion-14 {
flex-shrink: 0;
width: 1rem;
height: 1rem;
vertical-align: middle;
}
.emotion-24 {
Expand Down Expand Up @@ -339,6 +341,7 @@ input[type="checkbox"]:checked:disabled+.emotion-24 {
flex-shrink: 0;
width: 1.5rem;
height: 1.5rem;
vertical-align: middle;
}
.emotion-44 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ exports[`Drawer should render correctly 1`] = `
flex-shrink: 0;
width: var(--tonic-sizes-4x);
height: var(--tonic-sizes-4x);
vertical-align: middle;
}
.emotion-16 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ exports[`Menu should render correctly 1`] = `
flex-shrink: 0;
width: var(--tonic-sizes-4x);
height: var(--tonic-sizes-4x);
vertical-align: middle;
}
.emotion-10 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ exports[`Modal should render correctly 1`] = `
flex-shrink: 0;
width: var(--tonic-sizes-4x);
height: var(--tonic-sizes-4x);
vertical-align: middle;
}
.emotion-16 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ exports[`SearchInput should render correctly 1`] = `
}
.emotion-4 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding-left: calc(.75rem - .0625rem);
padding-right: var(--tonic-space-2x);
}
Expand All @@ -108,6 +116,7 @@ exports[`SearchInput should render correctly 1`] = `
flex-shrink: 0;
width: var(--tonic-sizes-4x);
height: var(--tonic-sizes-4x);
vertical-align: middle;
}
.emotion-8 {
Expand Down Expand Up @@ -298,6 +307,14 @@ exports[`SearchInput should render correctly 1`] = `
}
.emotion-24 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding-left: var(--tonic-space-3x);
padding-right: var(--tonic-space-2x);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/react/src/search-input/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ const useSearchInputLoadingIconStyle = ({ variant }) => {
: '2x';

return {
display: 'flex',
alignItems: 'center',
pl,
pr,
};
Expand All @@ -122,6 +124,8 @@ const useSearchInputSearchIconStyle = ({ variant }) => {
const pr = '2x';

return {
display: 'flex',
alignItems: 'center',
pl,
pr,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ exports[`Tree should render correctly 1`] = `
flex-shrink: 0;
width: var(--tonic-sizes-4x);
height: var(--tonic-sizes-4x);
vertical-align: middle;
}
.emotion-14 {
Expand Down

0 comments on commit 6a301aa

Please sign in to comment.