Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rtl: rtl ui polish #387

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/Button/BaseButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Badge } from '../Badge';
import { Breakpoints, useMatchMedia } from '../../hooks/useMatchMedia';
import { mergeClasses } from '../../shared/utilities';
import { Loader, LoaderSize } from '../Loader';
import { useCanvasDirection } from '../../hooks/useCanvasDirection';

import styles from './button.module.scss';

Expand Down Expand Up @@ -61,6 +62,8 @@ export const BaseButton: FC<InternalButtonProps> = React.forwardRef(
const smallScreenActive: boolean = useMatchMedia(Breakpoints.Small);
const xSmallScreenActive: boolean = useMatchMedia(Breakpoints.XSmall);

const htmlDir: string = useCanvasDirection();

const contextuallyDisabled: Disabled = useContext(DisabledContext);
const mergedDisabled: boolean = configContextProps.noDisabledContext
? disabled
Expand Down Expand Up @@ -103,6 +106,7 @@ export const BaseButton: FC<InternalButtonProps> = React.forwardRef(
},
{ [styles.dropShadow]: dropShadow },
{ [styles.floating]: floatingButtonProps?.enabled },
{ [styles.buttonRtl]: htmlDir === 'rtl' },
]);

const buttonBaseClassNames: string = mergeClasses([
Expand Down
19 changes: 15 additions & 4 deletions src/components/Button/SplitButton/SplitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { Icon, IconName, IconSize } from '../../Icon';
import { Breakpoints, useMatchMedia } from '../../../hooks/useMatchMedia';
import { mergeClasses } from '../../../shared/utilities';
import { useCanvasDirection } from '../../../hooks/useCanvasDirection';

import styles from '../button.module.scss';

Expand Down Expand Up @@ -48,6 +49,8 @@ export const SplitButton: FC<SplitButtonProps> = React.forwardRef(
const smallScreenActive: boolean = useMatchMedia(Breakpoints.Small);
const xSmallScreenActive: boolean = useMatchMedia(Breakpoints.XSmall);

const htmlDir: string = useCanvasDirection();

const contextuallyDisabled: Disabled = useContext(DisabledContext);
const mergedDisabled: boolean = configContextProps.noDisabledContext
? disabled
Expand Down Expand Up @@ -181,11 +184,19 @@ export const SplitButton: FC<SplitButtonProps> = React.forwardRef(
style={style}
type="button"
>
{htmlDir === 'rtl' && (
<span
className={splitDividerClassNames}
aria-hidden="true"
></span>
)}
{getButtonIcon()}
<span
className={splitDividerClassNames}
aria-hidden="true"
></span>
{htmlDir !== 'rtl' && (
<span
className={splitDividerClassNames}
aria-hidden="true"
></span>
)}
</button>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Button/TwoStateButton/TwoStateButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Badge } from '../../Badge';
import { Icon, IconSize } from '../../Icon';
import { Breakpoints, useMatchMedia } from '../../../hooks/useMatchMedia';
import { mergeClasses } from '../../../shared/utilities';
import { useCanvasDirection } from '../../../hooks/useCanvasDirection';

import styles from '../button.module.scss';

Expand Down Expand Up @@ -53,6 +54,8 @@ export const TwoStateButton: FC<TwoStateButtonProps> = React.forwardRef(
const smallScreenActive: boolean = useMatchMedia(Breakpoints.Small);
const xSmallScreenActive: boolean = useMatchMedia(Breakpoints.XSmall);

const htmlDir: string = useCanvasDirection();

const contextuallyDisabled: Disabled = useContext(DisabledContext);
const mergedDisabled: boolean = configContextProps.noDisabledContext
? disabled
Expand Down Expand Up @@ -98,6 +101,7 @@ export const TwoStateButton: FC<TwoStateButtonProps> = React.forwardRef(
{ [styles.left]: alignText === ButtonTextAlign.Left },
{ [styles.right]: alignText === ButtonTextAlign.Right },
{ [styles.disabled]: allowDisabledFocus || mergedDisabled },
{ [styles.buttonRtl]: htmlDir === 'rtl' },
]);

const buttonTextClassNames: string = mergeClasses([
Expand Down
126 changes: 126 additions & 0 deletions src/components/Button/button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,132 @@
}
}

.button-rtl {
.icon + .button-text-large:not(:empty) {
margin-left: 0;
margin-right: $button-spacer-large;
}

.icon + .button-text-medium:not(:empty) {
margin-left: 0;
margin-right: $button-spacer-medium;
}

.icon + .button-text-small:not(:empty) {
margin-left: 0;
margin-right: $button-spacer-small;
}

&.split-left {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
border-bottom-right-radius: $corner-radius-s;
border-top-right-radius: $corner-radius-s;

&.pill-shape {
border-bottom-right-radius: $corner-radius-xl;
border-top-right-radius: $corner-radius-xl;
}

.button-text-large {
&.counter {
margin-left: 0;
margin-right: $space-xs;
}
}

.button-text-medium {
&.counter {
margin-left: 0;
margin-right: $space-xs;
}
}

.button-text-small {
&.counter {
margin-left: 0;
margin-right: $space-xxs;
}
}
}

&.split-right {
border-bottom-left-radius: $corner-radius-s;
border-top-left-radius: $corner-radius-s;
border-bottom-right-radius: 0;
border-top-right-radius: 0;

&.pill-shape {
border-bottom-left-radius: $corner-radius-xl;
border-top-left-radius: $corner-radius-xl;
}

.button-text-large {
&.counter {
margin-left: $space-xs;
margin-right: 0;
}
}

.button-text-medium {
&.counter {
margin-left: $space-xs;
margin-right: 0;
}
}

.button-text-small {
&.counter {
margin-left: $space-xxs;
margin-right: 0;
}
}
}

&.split-button {
.split-divider-large {
left: 50px;
right: unset;
}

.split-divider-medium {
left: 42px;
right: unset;
}

.split-divider-small {
left: 34px;
right: unset;
}
}

&.floating {
left: 40px;
right: unset;
}

.button-text-large {
&.counter {
margin-left: 0;
margin-right: $space-xs;
}
}

.button-text-medium {
&.counter {
margin-left: 0;
margin-right: $space-xs;
}
}

.button-text-small {
&.counter {
margin-left: 0;
margin-right: $space-xxs;
}
}
}

:global(.focus-visible) {
.button {
&.focus-visible,
Expand Down
4 changes: 4 additions & 0 deletions src/components/CheckBox/CheckBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { generateId, mergeClasses } from '../../shared/utilities';
import { CheckboxProps, LabelAlign, LabelPosition, SelectorSize } from './';
import { Breakpoints, useMatchMedia } from '../../hooks/useMatchMedia';
import { FormItemInputContext } from '../Form/Context';
import { useCanvasDirection } from '../../hooks/useCanvasDirection';

import styles from './checkbox.module.scss';

Expand Down Expand Up @@ -41,6 +42,8 @@ export const CheckBox: FC<CheckboxProps> = React.forwardRef(
const smallScreenActive: boolean = useMatchMedia(Breakpoints.Small);
const xSmallScreenActive: boolean = useMatchMedia(Breakpoints.XSmall);

const htmlDir: string = useCanvasDirection();

const checkBoxId = useRef<string>(id || generateId());
const [isChecked, setIsChecked] = useState<boolean>(
defaultChecked || checked
Expand Down Expand Up @@ -86,6 +89,7 @@ export const CheckBox: FC<CheckboxProps> = React.forwardRef(
{ [styles.selectorSmall]: mergedSize === SelectorSize.Small },
classNames,
{ [styles.disabled]: allowDisabledFocus || mergedDisabled },
{ [styles.selectorRtl]: htmlDir === 'rtl' },
{ ['in-form-item']: mergedFormItemInput },
]);

Expand Down
56 changes: 56 additions & 0 deletions src/components/CheckBox/checkbox.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,62 @@
cursor: not-allowed;
}
}

&-rtl {
.selector-label {
&-end {
margin-left: 0;
margin-right: $space-xs;
}

&-start {
margin-left: $space-xs;
margin-right: 0;
}
}

&-large {
.selector-label {
&-end {
margin-left: 0;
margin-right: $space-m;
}

&-start {
margin-left: $space-m;
margin-right: 0;
}
}
}

&-medium {
.selector-label {
&-end {
margin-left: 0;
margin-right: $space-xs;
}

&-start {
margin-left: $space-xs;
margin-right: 0;
}
}
}

&-small {
.selector-label {
&-end {
margin-left: 0;
margin-right: $space-xxs;
}

&-start {
margin-left: $space-xxs;
margin-right: 0;
}
}
}
}
}

:global(.focus-visible) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export default function generateRangePicker<DateType>(
>
<Icon
path={IconName.mdiArrowRightThin}
rotate={htmlDir === 'rtl' ? 180 : 0}
size={IconSize.Medium}
/>
</span>
Expand Down Expand Up @@ -252,6 +253,7 @@ export default function generateRangePicker<DateType>(
[styles.pickerStatusSuccess]:
mergedStatus === 'success',
},
{ [styles.pickerRtl]: htmlDir === 'rtl' },
{ ['in-form-item']: mergedFormItemInput },
classNames,
])}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export default function generatePicker<DateType>(
[styles.pickerStatusSuccess]:
mergedStatus === 'success',
},
{ [styles.pickerRtl]: htmlDir === 'rtl' },
{ ['in-form-item']: mergedFormItemInput },
classNames,
])}
Expand Down
17 changes: 17 additions & 0 deletions src/components/DateTimePicker/DatePicker/Styles/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ $picker-input-padding-vertical: max(
padding: $padding-top $padding-horizontal $padding-bottom 0;
}

@mixin picker-padding-rtl($input-height, $font-size, $padding-horizontal) {
// font height is probably 22.0001, So using floor is better
dkilgore-eightfold marked this conversation as resolved.
Show resolved Hide resolved
$font-height: floor(
strip-units($font-size) * strip-units($padding-horizontal)
) + 2;
$padding-top: max(
calc((strip-units($input-height) - strip-units($font-height)) / 2),
0
);
$padding-bottom: max(
strip-units($input-height) - strip-units($font-height) -
strip-units($padding-top),
0
);
padding: $padding-top 0 $padding-bottom $padding-horizontal;
}

// Picker css reset
@mixin reset-component() {
box-sizing: border-box;
Expand Down
Loading