style: 🎨 Use Logical Style properties to apply same styles based on Language Direction (dir)

This commit is contained in:
Mohanad Alrwaihy 2024-02-29 23:32:06 +03:00
parent 354da4bc56
commit adf910306b
20 changed files with 35 additions and 34 deletions

View File

@ -1,5 +1,5 @@
.body { .body {
padding-left: 20px; padding-inline-start: 20px;
grid-row: 2/3; grid-row: 2/3;
grid-column: 2 / 3; grid-column: 2 / 3;
} }

View File

@ -1,7 +1,7 @@
.menu { .menu {
width: 300px; width: 300px;
padding-right: 20px; padding-inline-end: 20px;
border-right: 1px solid var(--base300); border-inline-end: 1px solid var(--base300);
grid-row: 2 / 3; grid-row: 2 / 3;
grid-column: 1 / 2; grid-column: 1 / 2;
} }

View File

@ -63,7 +63,7 @@
.value { .value {
color: var(--base50); color: var(--base50);
margin-right: 20px; margin-inline-end: 20px;
} }
.track { .track {

View File

@ -13,5 +13,5 @@
.popup { .popup {
margin-top: -10px; margin-top: -10px;
margin-left: 30px; margin-inline-start: 30px;
} }

View File

@ -7,5 +7,5 @@
.tag { .tag {
text-align: center; text-align: center;
margin-bottom: 10px; margin-bottom: 10px;
margin-right: 20px; margin-inline-end: 20px;
} }

View File

@ -58,6 +58,6 @@
gap: 20px; gap: 20px;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding-right: 0; padding-inline-end: 0;
} }
} }

View File

@ -12,7 +12,7 @@ import ReferrersTable from 'components/metrics/ReferrersTable';
import ScreenTable from 'components/metrics/ScreenTable'; import ScreenTable from 'components/metrics/ScreenTable';
import EventsTable from 'components/metrics/EventsTable'; import EventsTable from 'components/metrics/EventsTable';
import SideNav from 'components/layout/SideNav'; import SideNav from 'components/layout/SideNav';
import { useNavigation, useMessages } from 'components/hooks'; import { useNavigation, useMessages, useLocale } from 'components/hooks';
import LinkButton from 'components/common/LinkButton'; import LinkButton from 'components/common/LinkButton';
import styles from './WebsiteExpandedView.module.css'; import styles from './WebsiteExpandedView.module.css';
@ -39,6 +39,7 @@ export default function WebsiteExpandedView({
websiteId: string; websiteId: string;
domainName?: string; domainName?: string;
}) { }) {
const { dir } = useLocale();
const { formatMessage, labels } = useMessages(); const { formatMessage, labels } = useMessages();
const { const {
router, router,
@ -122,7 +123,7 @@ export default function WebsiteExpandedView({
<div className={styles.layout}> <div className={styles.layout}>
<div className={styles.menu}> <div className={styles.menu}>
<LinkButton href={pathname} className={styles.back} variant="quiet" scroll={false}> <LinkButton href={pathname} className={styles.back} variant="quiet" scroll={false}>
<Icon rotate={180}> <Icon rotate={dir === 'rtl' ? 0 : 180}>
<Icons.ArrowRight /> <Icons.ArrowRight />
</Icon> </Icon>
<Text>{formatMessage(labels.back)}</Text> <Text>{formatMessage(labels.back)}</Text>

View File

@ -27,7 +27,7 @@
} }
.icon { .icon {
margin-right: 10px; margin-inline-end: 10px;
} }
.time { .time {

View File

@ -11,5 +11,5 @@
} }
.icon { .icon {
margin-right: 10px; margin-inline-end: 10px;
} }

View File

@ -35,5 +35,5 @@ a.item.selected,
.submenu a.item { .submenu a.item {
color: var(--base600); color: var(--base600);
margin-left: 40px; margin-inline-start: 40px;
} }

View File

@ -6,7 +6,7 @@
z-index: var(--z-index-popup); z-index: var(--z-index-popup);
border-radius: 5px; border-radius: 5px;
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
margin-left: 10px; margin-inline-start: 10px;
} }
.item { .item {

View File

@ -18,7 +18,7 @@
font-size: 11px; font-size: 11px;
color: var(--base600); color: var(--base600);
text-align: right; text-align: right;
margin-right: 10px; margin-inline-end: 10px;
} }
.name { .name {

View File

@ -13,12 +13,11 @@
} }
.buttons button:first-child { .buttons button:first-child {
border-top-right-radius: 0; border-start-end-radius: 0;
border-bottom-right-radius: 0; border-end-end-radius: 0;
} }
.buttons button:last-child { .buttons button:last-child {
border-top-left-radius: 0; border-start-start-radius: 0;
border-bottom-left-radius: 0; border-end-start-radius: 0;
border-left: 1px solid var(--base400) !important;
} }

View File

@ -1,4 +1,4 @@
import { useDateRange } from 'components/hooks'; import { useDateRange, useLocale } from 'components/hooks';
import { isAfter } from 'date-fns'; import { isAfter } from 'date-fns';
import { getOffsetDateRange } from 'lib/date'; import { getOffsetDateRange } from 'lib/date';
import { Button, Icon, Icons } from 'react-basics'; import { Button, Icon, Icons } from 'react-basics';
@ -7,6 +7,7 @@ import styles from './WebsiteDateFilter.module.css';
import { DateRange } from 'lib/types'; import { DateRange } from 'lib/types';
export function WebsiteDateFilter({ websiteId }: { websiteId: string }) { export function WebsiteDateFilter({ websiteId }: { websiteId: string }) {
const { dir } = useLocale();
const [dateRange, setDateRange] = useDateRange(websiteId); const [dateRange, setDateRange] = useDateRange(websiteId);
const { value, startDate, endDate, offset } = dateRange; const { value, startDate, endDate, offset } = dateRange;
const disableForward = const disableForward =
@ -25,12 +26,12 @@ export function WebsiteDateFilter({ websiteId }: { websiteId: string }) {
{value !== 'all' && ( {value !== 'all' && (
<div className={styles.buttons}> <div className={styles.buttons}>
<Button onClick={() => handleIncrement(-1)}> <Button onClick={() => handleIncrement(-1)}>
<Icon rotate={90}> <Icon rotate={dir === 'rtl' ? 270 : 90}>
<Icons.ChevronDown /> <Icons.ChevronDown />
</Icon> </Icon>
</Button> </Button>
<Button onClick={() => handleIncrement(1)} disabled={disableForward}> <Button onClick={() => handleIncrement(1)} disabled={disableForward}>
<Icon rotate={270}> <Icon rotate={dir === 'rtl' ? 90 : 270}>
<Icons.ChevronDown /> <Icons.ChevronDown />
</Icon> </Icon>
</Button> </Button>

View File

@ -7,7 +7,7 @@
.menu { .menu {
width: 240px; width: 240px;
padding-top: 34px; padding-top: 34px;
padding-right: 20px; padding-inline-end: 20px;
} }
.content { .content {

View File

@ -29,12 +29,12 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
border-right: 2px solid var(--base200); border-inline-end: 2px solid var(--base200);
padding: 1rem 2rem; padding: 1rem 2rem;
gap: var(--size500); gap: var(--size500);
font-weight: 600; font-weight: 600;
width: 200px; width: 200px;
margin-right: -2px; margin-inline-end: -2px;
} }
a.item { a.item {
@ -43,7 +43,7 @@ a.item {
.item.selected { .item.selected {
color: var(--base900); color: var(--base900);
border-right-color: var(--primary400); border-inline-end-color: var(--primary400);
background: var(--blue100); background: var(--blue100);
} }

View File

@ -29,7 +29,7 @@
.icon { .icon {
color: var(--base700); color: var(--base700);
margin-right: 1rem; margin-inline-end: 1rem;
} }
.actions { .actions {

View File

@ -1,7 +1,7 @@
.container { .container {
display: flex; display: flex;
align-items: center; align-items: center;
margin-left: 20px; margin-inline-start: 20px;
} }
.text { .text {
@ -13,5 +13,5 @@
.value { .value {
font-weight: 600; font-weight: 600;
margin-right: 4px; margin-inline-end: 4px;
} }

View File

@ -14,9 +14,9 @@
} }
.calendars > div + div { .calendars > div + div {
margin-left: 20px; margin-inline-start: 20px;
padding-left: 20px; padding-inline-start: 20px;
border-left: 1px solid var(--base300); border-inline-start: 1px solid var(--base300);
} }
.filter { .filter {
@ -41,7 +41,7 @@
.calendars > div + div { .calendars > div + div {
padding: 0; padding: 0;
margin-left: 0; margin-inline-start: 0;
margin-top: 20px; margin-top: 20px;
border: 0; border: 0;
} }

View File

@ -76,7 +76,7 @@
position: relative; position: relative;
width: 50px; width: 50px;
color: var(--base600); color: var(--base600);
border-left: 1px solid var(--base600); border-inline-start: 1px solid var(--base600);
padding-inline-start: 10px; padding-inline-start: 10px;
z-index: 1; z-index: 1;
} }