Skip to content

Commit

Permalink
fix(react-positioning,react-tabster): update styles to not use CSS sh…
Browse files Browse the repository at this point in the history
…orthands (#20842)
  • Loading branch information
layershifter authored Nov 30, 2021
1 parent 8cd4834 commit 967d6b7
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "update styles to not use CSS shorthands",
"packageName": "@fluentui/react-positioning",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "update styles to not use CSS shorthands",
"packageName": "@fluentui/react-tabster",
"email": "[email protected]",
"dependentChangeType": "patch"
}
91 changes: 44 additions & 47 deletions packages/react-positioning/src/createArrowStyles.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { shorthands } from '@fluentui/react-make-styles';
import type { MakeStylesStyleRule } from '@fluentui/react-make-styles';
import type { Theme } from '@fluentui/react-theme';

Expand Down Expand Up @@ -26,58 +27,54 @@ import type { Theme } from '@fluentui/react-theme';
* @param size - dimensions of the square arrow element in pixels.
*/
export function createArrowStyles(size?: number): MakeStylesStyleRule<Theme> {
return theme => {
const arrowHCBorderStyle = `1px solid transparent`;
const arrowHCBorder = {
borderRight: arrowHCBorderStyle,
borderBottom: arrowHCBorderStyle,
};
return theme => ({
position: 'absolute',
backgroundColor: 'inherit',
visibility: 'hidden',
zIndex: -1,

return {
position: 'absolute',
background: 'inherit',
visibility: 'hidden',
zIndex: -1,
...(size && {
aspectRatio: '1',
width: `${size}px`,
}),

...(size && {
aspectRatio: '1',
width: `${size}px`,
}),
':before': {
content: '""',
...shorthands.borderRadius('4px'),
position: 'absolute',
width: 'inherit',
height: 'inherit',
backgroundColor: 'inherit',
visibility: 'visible',
borderBottomRightRadius: theme.borderRadiusSmall,
transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',
},

':global([data-popper-placement])': {
':before': {
content: '""',
borderRadius: '4px',
position: 'absolute',
width: 'inherit',
height: 'inherit',
background: 'inherit',
visibility: 'visible',
borderBottomRightRadius: theme.borderRadiusSmall,
transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',
},

':global([data-popper-placement])': {
':before': arrowHCBorder,
// Special border for High Contrast mode
...shorthands.borderRight('1px', 'solid', 'transparent'),
...shorthands.borderBottom('1px', 'solid', 'transparent'),
},
},

// Popper sets data-popper-placement on the root element, which is used to align the arrow
':global([data-popper-placement^="top"])': {
bottom: 0,
'--angle': '0',
},
// Popper sets data-popper-placement on the root element, which is used to align the arrow
':global([data-popper-placement^="top"])': {
bottom: 0,
'--angle': '0',
},

':global([data-popper-placement^="right"])': {
left: 0,
'--angle': '90deg',
},
':global([data-popper-placement^="bottom"])': {
top: 0,
'--angle': '180deg',
},
':global([data-popper-placement^="left"])': {
right: 0,
'--angle': '270deg',
},
};
};
':global([data-popper-placement^="right"])': {
left: 0,
'--angle': '90deg',
},
':global([data-popper-placement^="bottom"])': {
top: 0,
'--angle': '180deg',
},
':global([data-popper-placement^="left"])': {
right: 0,
'--angle': '270deg',
},
});
}
4 changes: 2 additions & 2 deletions packages/react-tabster/src/hooks/useFocusIndicatorStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const createFocusOutlineStyle = (
} & CreateFocusIndicatorStyleRuleOptions = { style: {}, ...defaultOptions },
): MakeStylesStyle => ({
':focus-visible': {
outline: 'none',
outlineStyle: 'none',
},
[`${KEYBOARD_NAV_SELECTOR} :${options.selector || defaultOptions.selector}`]: getFocusOutlineStyles({
outlineColor: theme.colorStrokeFocus2,
Expand All @@ -96,7 +96,7 @@ export const createCustomFocusIndicatorStyle = (
options: CreateFocusIndicatorStyleRuleOptions = defaultOptions,
): MakeStylesStyleRule<Theme> => theme => ({
':focus-visible': {
outline: 'none',
outlineStyle: 'none',
},
[`${KEYBOARD_NAV_SELECTOR} :${options.selector || defaultOptions.selector}`]:
typeof rule === 'function' ? rule(theme) : rule,
Expand Down

0 comments on commit 967d6b7

Please sign in to comment.