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

refactor: replace right/left with inline corresponding values for better RTL support #560

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
93 changes: 40 additions & 53 deletions css/pico.amber.css
Original file line number Diff line number Diff line change
Expand Up @@ -664,17 +664,14 @@ section {
.container,
.container-fluid {
width: 100%;
margin-right: auto;
margin-left: auto;
padding-right: var(--pico-spacing);
padding-left: var(--pico-spacing);
margin-inline: auto;
padding-inline: var(--pico-spacing);
Comment on lines +667 to +668
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*-right and *-left can be merged into *-inline.

}

@media (min-width: 576px) {
.container {
max-width: 510px;
padding-right: 0;
padding-left: 0;
padding-inline: 0;
}
}
@media (min-width: 768px) {
Expand Down Expand Up @@ -847,8 +844,6 @@ blockquote {
display: block;
margin: var(--pico-typography-spacing-vertical) 0;
padding: var(--pico-spacing);
border-right: none;
border-left: 0.25rem solid var(--pico-blockquote-border-color);
border-inline-start: 0.25rem solid var(--pico-blockquote-border-color);
border-inline-end: none;
}
Expand Down Expand Up @@ -1108,7 +1103,6 @@ td {
background-color: var(--pico-background-color);
color: var(--pico-color);
font-weight: var(--pico-font-weight);
text-align: left;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left and start are identical so they are not needed at the current time when IE doesn't exist.

text-align: start;
}

Expand Down Expand Up @@ -1429,8 +1423,6 @@ label[aria-disabled=true] input[disabled] {
[type=time],
[type=week],
[type=range])[aria-invalid] {
padding-right: calc(var(--pico-form-element-spacing-horizontal) + 1.5rem) !important;
padding-left: var(--pico-form-element-spacing-horizontal);
Comment on lines -1432 to -1433
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same redundancy for IE

padding-inline-start: var(--pico-form-element-spacing-horizontal) !important;
padding-inline-end: calc(var(--pico-form-element-spacing-horizontal) + 1.5rem) !important;
background-position: center right 0.75rem;
Expand Down Expand Up @@ -1500,8 +1492,6 @@ select::-ms-expand {
background-color: transparent;
}
select:not([multiple], [size]) {
padding-right: calc(var(--pico-form-element-spacing-horizontal) + 1.5rem);
padding-left: var(--pico-form-element-spacing-horizontal);
padding-inline-start: var(--pico-form-element-spacing-horizontal);
padding-inline-end: calc(var(--pico-form-element-spacing-horizontal) + 1.5rem);
background-image: var(--pico-icon-chevron);
Expand Down Expand Up @@ -1707,7 +1697,7 @@ label:has([type=checkbox], [type=radio]) {
input:not([type=checkbox], [type=radio], [type=range], [type=file]):is([type=date], [type=datetime-local], [type=month], [type=time], [type=week]) {
--pico-icon-position: 0.75rem;
--pico-icon-width: 1rem;
padding-right: calc(var(--pico-icon-width) + var(--pico-icon-position));
padding-inline-end: calc(var(--pico-icon-width) + var(--pico-icon-position));
background-image: var(--pico-icon-date);
background-position: center right var(--pico-icon-position);
background-size: var(--pico-icon-width) auto;
Expand All @@ -1723,8 +1713,8 @@ input:not([type=checkbox], [type=radio], [type=range], [type=file])[type=time] {
[type=time]::-webkit-calendar-picker-indicator,
[type=week]::-webkit-calendar-picker-indicator {
width: var(--pico-icon-width);
margin-right: calc(var(--pico-icon-width) * -1);
margin-left: var(--pico-icon-position);
margin-inline-start: var(--pico-icon-position);
margin-inline-end: calc(var(--pico-icon-width) * -1);
opacity: 0;
}

Expand All @@ -1734,28 +1724,28 @@ input:not([type=checkbox], [type=radio], [type=range], [type=file])[type=time] {
[type=month],
[type=time],
[type=week] {
padding-right: var(--pico-form-element-spacing-horizontal) !important;
padding-inline-end: var(--pico-form-element-spacing-horizontal) !important;
background-image: none !important;
}
}
[dir=rtl] :is([type=date], [type=datetime-local], [type=month], [type=time], [type=week]) {
text-align: right;
text-align: start;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start in [dir=rtl] is the right position.

}

/**
* Input type file
*/
[type=file] {
--pico-color: var(--pico-muted-color);
margin-left: calc(var(--pico-outline-width) * -1);
margin-inline-start: calc(var(--pico-outline-width) * -1);
padding: calc(var(--pico-form-element-spacing-vertical) * 0.5) 0;
padding-left: var(--pico-outline-width);
padding-inline-start: var(--pico-outline-width);
border: 0;
border-radius: 0;
background: none;
}
[type=file]::file-selector-button {
margin-right: calc(var(--pico-spacing) / 2);
margin-inline-end: calc(var(--pico-spacing) / 2);
padding: calc(var(--pico-form-element-spacing-vertical) * 0.5) var(--pico-form-element-spacing-horizontal);
}
[type=file]:is(:hover, :active, :focus)::file-selector-button {
Expand Down Expand Up @@ -1909,7 +1899,7 @@ details summary::after {
width: 1rem;
height: 1rem;
margin-inline-start: calc(var(--pico-spacing, 1rem) * 0.5);
float: right;
float: inline-end;
transform: rotate(-90deg);
background-image: var(--pico-icon-chevron);
background-position: right center;
Expand All @@ -1931,7 +1921,7 @@ details summary:focus-visible:not([role]) {
}
details summary[role=button] {
width: 100%;
text-align: left;
text-align: start;
}
details summary[role=button]::after {
height: calc(1rem * var(--pico-line-height, 1.5));
Expand All @@ -1947,10 +1937,9 @@ details[open] > summary::after {
}

[dir=rtl] details summary {
text-align: right;
text-align: start;
}
[dir=rtl] details summary::after {
float: left;
background-position: left center;
}

Expand All @@ -1966,17 +1955,17 @@ article {
}
article > header,
article > footer {
margin-right: calc(var(--pico-block-spacing-horizontal) * -1);
margin-left: calc(var(--pico-block-spacing-horizontal) * -1);
margin-inline-start: calc(var(--pico-block-spacing-horizontal) * -1);
margin-inline-end: calc(var(--pico-block-spacing-horizontal) * -1);
padding: calc(var(--pico-block-spacing-vertical) * 0.66) var(--pico-block-spacing-horizontal);
background-color: var(--pico-card-sectioning-background-color);
}
article > header {
margin-top: calc(var(--pico-block-spacing-vertical) * -1);
margin-bottom: var(--pico-block-spacing-vertical);
border-bottom: var(--pico-border-width) solid var(--pico-card-border-color);
border-top-right-radius: var(--pico-border-radius);
border-top-left-radius: var(--pico-border-radius);
border-start-start-radius: var(--pico-border-radius);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be confusing but border-*-*-radius has also inline/block corresponding.

ref. https://developer.mozilla.org/en-US/docs/Web/CSS/border-end-end-radius

border-start-end-radius: var(--pico-border-radius);
}
article > footer {
margin-top: var(--pico-block-spacing-vertical);
Expand All @@ -2000,7 +1989,7 @@ details.dropdown > a::after {
width: 1rem;
height: calc(1rem * var(--pico-line-height, 1.5));
margin-inline-start: 0.25rem;
float: right;
float: inline-start;
transform: rotate(0deg) translateX(0.2rem);
background-image: var(--pico-icon-chevron);
background-position: right center;
Expand Down Expand Up @@ -2176,18 +2165,18 @@ label > details.dropdown {
[role=group] > *:not(:first-child),
[role=group] input:not([type=checkbox], [type=radio]):not(:first-child),
[role=group] select:not(:first-child) {
margin-left: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
margin-inline-start: 0;
border-start-start-radius: 0;
border-end-start-radius: 0;
}
[role=search] > *:not(:last-child),
[role=search] input:not([type=checkbox], [type=radio]):not(:last-child),
[role=search] select:not(:last-child),
[role=group] > *:not(:last-child),
[role=group] input:not([type=checkbox], [type=radio]):not(:last-child),
[role=group] select:not(:last-child) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-start-end-radius: 0;
border-end-end-radius: 0;
}
[role=search] > *:focus,
[role=search] input:not([type=checkbox], [type=radio]):focus,
Expand All @@ -2211,7 +2200,7 @@ label > details.dropdown {
[role=group] [role=button]:not(:first-child),
[role=group] input:not([type=checkbox], [type=radio]):not(:first-child),
[role=group] select:not(:first-child) {
margin-left: calc(var(--pico-border-width) * -1);
margin-inline-start: calc(var(--pico-border-width) * -1);
}
[role=search] button,
[role=search] [type=submit],
Expand Down Expand Up @@ -2266,12 +2255,12 @@ label > details.dropdown {
}

[role=search] > *:first-child {
border-top-left-radius: 5rem;
border-bottom-left-radius: 5rem;
border-start-start-radius: 5rem;
border-end-start-radius: 5rem;
}
[role=search] > *:last-child {
border-top-right-radius: 5rem;
border-bottom-right-radius: 5rem;
border-start-end-radius: 5rem;
border-end-end-radius: 5rem;
}

/**
Expand Down Expand Up @@ -2355,20 +2344,20 @@ dialog article > header > * {
}
dialog article > header .close, dialog article > header :is(a, button)[rel=prev] {
margin: 0;
margin-left: var(--pico-spacing);
margin-inline-start: var(--pico-spacing);
padding: 0;
float: right;
float: inline-end;
}
dialog article > footer {
text-align: right;
text-align: end;
}
dialog article > footer button,
dialog article > footer [role=button] {
margin-bottom: 0;
}
dialog article > footer button:not(:first-of-type),
dialog article > footer [role=button]:not(:first-of-type) {
margin-left: calc(var(--pico-spacing) * 0.5);
margin-inline-start: calc(var(--pico-spacing) * 0.5);
}
dialog article .close, dialog article :is(a, button)[rel=prev] {
display: block;
Expand All @@ -2394,7 +2383,7 @@ dialog:not([open]), dialog[open=false] {
}

.modal-is-open {
padding-right: var(--pico-scrollbar-width, 0px);
padding-inline-end: var(--pico-scrollbar-width, 0px);
overflow: hidden;
pointer-events: none;
touch-action: none;
Expand Down Expand Up @@ -2442,7 +2431,7 @@ dialog:not([open]), dialog[open=false] {
* Nav
*/
:where(nav li)::before {
float: left;
float: inline-start;
content: "​";
}

Expand All @@ -2464,11 +2453,11 @@ nav ul {
}
nav ol:first-of-type,
nav ul:first-of-type {
margin-left: calc(var(--pico-nav-element-spacing-horizontal) * -1);
margin-inline-start: calc(var(--pico-nav-element-spacing-horizontal) * -1);
}
nav ol:last-of-type,
nav ul:last-of-type {
margin-right: calc(var(--pico-nav-element-spacing-horizontal) * -1);
margin-inline-end: calc(var(--pico-nav-element-spacing-horizontal) * -1);
}
nav li {
display: inline-block;
Expand All @@ -2490,9 +2479,8 @@ nav li [type=button],
nav li input:not([type=checkbox], [type=radio], [type=range], [type=file]),
nav li select {
height: auto;
margin-right: inherit;
margin-bottom: 0;
margin-left: inherit;
margin-inline: inherit;
padding: calc(var(--pico-nav-link-spacing-vertical) - var(--pico-border-width) * 2) var(--pico-nav-link-spacing-horizontal);
}
nav[aria-label=breadcrumb] {
Expand Down Expand Up @@ -2642,9 +2630,8 @@ progress::-moz-progress-bar {
padding: 0;
transform: translate(-50%, 0rem);
border-top: 0.3rem solid;
border-right: 0.3rem solid transparent;
border-left: 0.3rem solid transparent;
border-radius: 0;
border-inline: 0.3rem solid transparent;
background-color: transparent;
content: "";
color: var(--pico-tooltip-background-color);
Expand Down Expand Up @@ -2681,7 +2668,7 @@ progress::-moz-progress-bar {
[data-tooltip][data-placement=right]:after {
transform: translate(-0.3rem, -50%);
border: 0.3rem solid transparent;
border-right: 0.3rem solid;
border-inline-end: 0.3rem solid;
}
[data-tooltip]:focus::before, [data-tooltip]:focus::after, [data-tooltip]:hover::before, [data-tooltip]:hover::after {
opacity: 1;
Expand Down
2 changes: 1 addition & 1 deletion css/pico.amber.min.css

Large diffs are not rendered by default.

Loading