Skip to content

Commit

Permalink
Upgrade to Polaris v12 styles (#388)
Browse files Browse the repository at this point in the history
* Add ability to preview Polaris v12
* Pin the @shopify/polaris to 11.26 in package.json
* Fix banners
* Fix styling, buttons and typography
* Add `polaris_html_classes` helper (#366)
* Update html to better suit
* Fix OptionList Checkbox styles (#367)
* Update cards
* Add Inter font (#371)
* Fix path to font
* Fix Modals
* Scope ul css better on cards
* Fix pagination
* Fix ActionLists and Page -> ActionMenu
* Minor padding adjustment
* Fix NavigationList
* Improve preview
* Fix Popover
* Fix filter popovers
* Fix Tooltips
* Improve banners v12 styles (#379)
* Fix FormBuilder errors_summary rendering within page (#381)
* Fix padding for card without title (#382)
* Improve styles for banners within cards
* Fix Buttons
* Fix ActionList buttons
* Fix ActionList--active
* Fix CalloutCard
* Fix SaveBar
* Fix shadow of active primary button
* Fix Headings
* Make iconOnly buttons square
* Fix card section borders
* Fix path to font on production
* Reduce font size of help text component
* Fix card section border paddings
* Fix list bottom margin
* Adjust Polaris-FormLayout padding
* Fix date and time input styles
* Popover fix - from using in real apps (#391)
* Remove unnecessary append_to_body argument
* Reorganize css files (#398)

---------

Co-authored-by: Bjorn Forsberg <bjorn@forsbergplustwo.com>
  • Loading branch information
kirillplatonov and forsbergplustwo authored Mar 18, 2024
1 parent cb7041b commit f30705f
Show file tree
Hide file tree
Showing 76 changed files with 1,552 additions and 3,788 deletions.
Binary file added app/assets/fonts/InterVariable-Italic.woff2
Binary file not shown.
Binary file added app/assets/fonts/InterVariable.woff2
Binary file not shown.
1 change: 1 addition & 0 deletions app/assets/icons/polaris/AlertTriangleIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/icons/polaris/CheckIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 38 additions & 14 deletions app/assets/javascripts/polaris_view_components.js
Original file line number Diff line number Diff line change
Expand Up @@ -2432,11 +2432,12 @@ class Tooltip extends Controller {
let tooltip = document.createElement("span");
tooltip.className = "Polaris-Tooltip";
tooltip.innerHTML = this.templateTarget.innerHTML;
this.tooltip = element.appendChild(tooltip);
const arrowElement = element.querySelector("[data-tooltip-arrow]");
document.body.appendChild(tooltip);
this.tooltip = tooltip;
const arrowElement = this.tooltip.querySelector(".Polaris-Tooltip-Arrow");
computePosition(element, this.tooltip, {
placement: this.positionValue,
middleware: [ offset(this.offsetValue), flip(), shift({
middleware: [ offset(10), flip(), shift({
padding: 5
}), arrow({
element: arrowElement
Expand All @@ -2446,20 +2447,43 @@ class Tooltip extends Controller {
left: `${x}px`,
top: `${y}px`
});
const {x: arrowX, y: arrowY} = middlewareData.arrow;
const staticSide = {
top: "bottom",
right: "left",
bottom: "top",
left: "right"
}[placement.split("-")[0]];
Object.assign(arrowElement.style, {
left: arrowX != null ? `${arrowX}px` : "",
top: arrowY != null ? `${arrowY}px` : "",
left: "",
top: "",
right: "",
bottom: "",
[staticSide]: "-4px"
bottom: ""
});
const {x: arrowX, y: arrowY} = middlewareData.arrow || {};
const primaryPlacement = placement.split("-")[0];
switch (primaryPlacement) {
case "top":
Object.assign(arrowElement.style, {
left: arrowX ? `${arrowX}px` : "",
bottom: "-4px"
});
break;

case "bottom":
Object.assign(arrowElement.style, {
left: arrowX ? `${arrowX}px` : "",
top: "-4px"
});
break;

case "left":
Object.assign(arrowElement.style, {
top: arrowY ? `${arrowY}px` : "",
right: "-4px"
});
break;

case "right":
Object.assign(arrowElement.style, {
top: arrowY ? `${arrowY}px` : "",
left: "-4px"
});
break;
}
}));
}
hide() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,65 @@ export default class extends Controller {
const element = event.currentTarget;

let tooltip = document.createElement("span");
tooltip.className = "Polaris-Tooltip"
tooltip.className = "Polaris-Tooltip";
tooltip.innerHTML = this.templateTarget.innerHTML;
this.tooltip = element.appendChild(tooltip);
document.body.appendChild(tooltip); // Append tooltip to body for better positioning control
this.tooltip = tooltip;

const arrowElement = element.querySelector("[data-tooltip-arrow]");
const arrowElement = this.tooltip.querySelector(".Polaris-Tooltip-Arrow");

computePosition(element, this.tooltip, {
placement: this.positionValue,
middleware: [
offset(this.offsetValue),
offset(10),
flip(),
shift({ padding: 5 }),
arrow({ element: arrowElement })
]
}).then(({x, y, placement, middlewareData}) => {
arrow({ element: arrowElement }),
],
}).then(({ x, y, placement, middlewareData }) => {
Object.assign(this.tooltip.style, {
left: `${x}px`,
top: `${y}px`,
})

const {x: arrowX, y: arrowY} = middlewareData.arrow;

const staticSide = {
top: 'bottom',
right: 'left',
bottom: 'top',
left: 'right',
}[placement.split('-')[0]];
});

// Reset any previously set styles on the arrow
Object.assign(arrowElement.style, {
left: arrowX != null ? `${arrowX}px` : '',
top: arrowY != null ? `${arrowY}px` : '',
left: '',
top: '',
right: '',
bottom: '',
[staticSide]: '-4px',
});
})

const { x: arrowX, y: arrowY } = middlewareData.arrow || {};
const primaryPlacement = placement.split('-')[0];

switch (primaryPlacement) {
case 'top':
Object.assign(arrowElement.style, {
left: arrowX ? `${arrowX}px` : '',
bottom: '-4px', // Aligns arrow to the bottom edge of the tooltip
});
break;
case 'bottom':
Object.assign(arrowElement.style, {
left: arrowX ? `${arrowX}px` : '',
top: '-4px', // Aligns arrow to the top edge of the tooltip
});
break;
case 'left':
Object.assign(arrowElement.style, {
top: arrowY ? `${arrowY}px` : '',
right: '-4px', // Aligns arrow to the right edge of the tooltip
});
break;
case 'right':
Object.assign(arrowElement.style, {
top: arrowY ? `${arrowY}px` : '',
left: '-4px', // Aligns arrow to the left edge of the tooltip
});
break;
}
});
}

hide() {
Expand Down
4,099 changes: 591 additions & 3,508 deletions app/assets/stylesheets/polaris_view_components.css

Large diffs are not rendered by default.

26 changes: 24 additions & 2 deletions app/assets/stylesheets/polaris_view_components.pcss
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
@import "./polaris_view_components/fonts.pcss";
@import "@shopify/polaris/build/esm/styles.css";
@import "./polaris_view_components/variables.pcss";

@import "./polaris_view_components/action_list.pcss";
@import "./polaris_view_components/banner.pcss";
@import "./polaris_view_components/button.pcss";
@import "./polaris_view_components/callout_card.pcss";
@import "./polaris_view_components/card.pcss";
@import "./polaris_view_components/custom.pcss";
@import "./polaris_view_components/data_table.pcss";
@import "./polaris_view_components/footer_help.pcss";
@import "./polaris_view_components/form_layout.pcss";
@import "./polaris_view_components/index_table.pcss";
@import "./polaris_view_components/list.pcss";
@import "./polaris_view_components/modal.pcss";
@import "./polaris_view_components/navigation.pcss";
@import "./polaris_view_components/navigation_list_component.pcss";
@import "./polaris_view_components/option_list.pcss";
@import "./polaris_view_components/page.pcss";
@import "./polaris_view_components/pagination.pcss";
@import "./polaris_view_components/popover.pcss";
@import "./polaris_view_components/save_bar.pcss";
@import "./polaris_view_components/shopify_navigation.pcss";
@import "./polaris_view_components/spacer_component.pcss";
@import "./polaris_view_components/tabs.pcss";
@import "./polaris_view_components/text_fields.pcss";
@import "./polaris_view_components/tooltip_component.pcss";
@import "./polaris_view_components/navigation_list_component.pcss";
@import "./polaris_view_components/custom.pcss";
25 changes: 25 additions & 0 deletions app/assets/stylesheets/polaris_view_components/action_list.pcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
html[class~="Polaris-Summer-Editions-2023"] .Polaris-ActionList {
.Polaris-ActionMenu-SecondaryAction a,
.Polaris-ActionMenu-SecondaryAction button,
.Polaris-ActionList__Item {
padding: var(--p-space-200);
background: transparent !important;

&:hover {
background: var(--p-color-bg-surface-secondary-hover) !important;
}

&.Polaris-ActionList--active {
background: var(--p-color-bg-surface-secondary-active) !important;
}

&.Polaris-ActionList--destructive {
&:hover {
background: var(--p-color-bg-surface-critical-hover) !important;
}
svg {
fill: var(--p-color-text-critical);
}
}
}
}
108 changes: 108 additions & 0 deletions app/assets/stylesheets/polaris_view_components/banner.pcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
html[class~="Polaris-Summer-Editions-2023"] .Polaris-Banner {
.Polaris-Banner__InlineIcon {
padding: var(--p-space-100);
border-radius: var(--p-border-radius-200);
width: 1.75rem;
height: 1.75rem;
}

.Polaris-Banner__DismissButton {
display: flex;
width: 1.75rem;
height: 1.75rem;
}

&.Polaris-Banner--withinPage {
.Polaris-Banner__TopBar {
padding: var(--p-space-300);

@media (min-width: 30.625em) {
border-top-left-radius: var(--p-border-radius-300);
border-top-right-radius: var(--p-border-radius-300);
}
}
&.Polaris-Banner--statusInfo {
.Polaris-Banner__TopBar, .Polaris-Banner__InlineIcon {
color: var(--p-color-text-info-on-bg-fill);
background-color: var(--p-color-bg-fill-info);

svg {
fill: var(--p-color-text-info-on-bg-fill) !important;
}
}
}
&.Polaris-Banner--statusSuccess {
.Polaris-Banner__TopBar, .Polaris-Banner__InlineIcon {
color: var(--p-color-text-success-on-bg-fill);
background-color: var(--p-color-bg-fill-success);

svg {
fill: var(--p-color-text-success-on-bg-fill) !important;
}
}
}
&.Polaris-Banner--statusWarning {
.Polaris-Banner__TopBar, .Polaris-Banner__InlineIcon {
color: var(--p-color-text-warning-on-bg-fill);
background-color: var(--p-color-bg-fill-warning);

svg {
fill: var(--p-color-text-warning-on-bg-fill) !important;
}
}
}
&.Polaris-Banner--statusCritical {
.Polaris-Banner__TopBar, .Polaris-Banner__InlineIcon {
color: var(--p-color-text-critical-on-bg-fill);
background-color: var(--p-color-bg-fill-critical);

svg {
fill: var(--p-color-text-critical-on-bg-fill) !important;
}
}
}
}

&.Polaris-Banner--onlyTitle {
.Polaris-Banner__TopBar {
@media (min-width: 30.625em) {
border-radius: var(--p-border-radius-300) !important;
}
}
}

&.Polaris-Banner--withinContentContainer {
.Polaris-Banner__InlineIcon {
padding: calc(var(--p-space-100) * -1);
margin-left: calc(var(--p-space-100) * -1);
margin-bottom: calc(var(--p-space-200) * -1);
}

.Polaris-Banner__DismissButton {
padding: calc(var(--p-space-100) * -1);
margin-top: calc(var(--p-space-100) * -1);
margin-right: calc(var(--p-space-100) * -1);
margin-bottom: calc(var(--p-space-100) * -1);
}

.Polaris-Banner__ContainerContentWrapper {
margin-top: 2px;
}

&.Polaris-Banner--statusInfo {
background-color: var(--p-color-bg-surface-info);
}

&.Polaris-Banner--statusSuccess {
background-color: var(--p-color-bg-surface-success);
}

&.Polaris-Banner--statusWarning {
background-color: var(--p-color-bg-surface-warning);
}

&.Polaris-Banner--statusCritical {
background-color: var(--p-color-bg-surface-critical);
}
}
}
Loading

0 comments on commit f30705f

Please sign in to comment.