Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b2b54e7
fix: WIP Polaris token validation
aaronccasanova Dec 3, 2021
1ab455f
Enhance custom-properties-allowed-list plugin
aaronccasanova Dec 4, 2021
8e9ce45
updated README with additional docs and run instructions
Dec 6, 2021
0e7ce6c
reverting TextContainer.scss will followup with fixes in separate PR
Dec 6, 2021
e531fde
fix: Update error message
aaronccasanova Dec 6, 2021
db613dd
docs: Update README
aaronccasanova Dec 6, 2021
098d2bc
fix: Update plugin to use postcss-value-parser
aaronccasanova Dec 6, 2021
79e358e
docs: Update README
aaronccasanova Dec 6, 2021
5e2c85b
Merge branch 'v8.0.0-major' of https://github.com/Shopify/polaris-rea…
aaronccasanova Dec 7, 2021
1f795f9
Improve custom-properties-allowed-list plugin
aaronccasanova Dec 8, 2021
333a25a
fix: Remove unused npm script
aaronccasanova Dec 8, 2021
5563716
fix: Move Stylelint config and plugins out of 'scripts' directory
aaronccasanova Dec 8, 2021
587c7e6
fix: Revert tsconfig changes
aaronccasanova Dec 8, 2021
023e6d3
fix: Update all failing custom properties
aaronccasanova Dec 8, 2021
0b7a56c
fix: Move Stylelint config to .stylelintrc.js
aaronccasanova Dec 8, 2021
b007140
fix: Formatting errors
aaronccasanova Dec 8, 2021
810e797
fix: Cast custom properties objects to React.CSSProperties
aaronccasanova Dec 8, 2021
1cbf188
fix: Revert vscode settings changes
aaronccasanova Dec 9, 2021
9a3e1f4
docs: Simplify README link
aaronccasanova Dec 9, 2021
d504e5c
docs: Fix typo in unreleased-v8
aaronccasanova Dec 9, 2021
6fc6590
Merge branch 'v8.0.0-major' of https://github.com/Shopify/polaris-rea…
aaronccasanova Dec 9, 2021
5f2552b
Merge branch 'v9.0.0-major' of https://github.com/Shopify/polaris-rea…
aaronccasanova Dec 10, 2021
48d1c5b
fix: Update box-shadow tokens
aaronccasanova Dec 10, 2021
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
5 changes: 1 addition & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@ node_modules
/examples
/build
/build-internal

index.esnext
index.js
index.mjs
/src/styles/polaris-tokens
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ node_modules
.DS_Store
*.scss.d.ts
.idea

index.esnext
index.js
index.mjs
6 changes: 1 addition & 5 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ node_modules
/build
/build-internal

/package.json

index.esnext
index.js
index.mjs
/package.json
26 changes: 26 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const path = require('path');

const {tokenList} = require('./build/cjs/token-list');

/**
* Allowed custom property names in Polaris component styles.
*/
const polarisComponentCustomProperties = /--pc-.+/;

module.exports = {
extends: ['@shopify/stylelint-plugin/prettier'],
plugins: [
path.join(__dirname, './stylelint/plugins/custom-properties-allowed-list'),
],
rules: {
'@shopify/custom-properties-allowed-list': {
allowedProperties: [
'--polaris-version-number',
polarisComponentCustomProperties,
],
allowedValues: {
'/.+/': [polarisComponentCustomProperties, ...tokenList],
},
},
},
};
3 changes: 3 additions & 0 deletions UNRELEASED-v8.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Use [the changelog guidelines](/documentation/Versioning%20and%20changelog.md) t
- Removed unnecessary `--p-border-radius-` properties and moved border-radius custom properties to tokens ([#4763](https://github.com/Shopify/polaris-react/pull/4763))
- Dropped support for node < 16 ([#4778](https://github.com/Shopify/polaris-react/pull/4778))
- Removed `build/styles` directory from build output ([#4728](https://github.com/Shopify/polaris-react/pull/4728))
- Updated `--global-ribbon-height` CSS custom property to `--pc-frame-global-ribbon-height` ([#4804](https://github.com/Shopify/polaris-react/pull/4804))
- Updated `--p-frame-offset` CSS custom property to `--pc-frame-offset` ([#4804](https://github.com/Shopify/polaris-react/pull/4804))
- Updated all `--top-bar-*` CSS custom properties to `--pc-top-bar-*` ([#4804](https://github.com/Shopify/polaris-react/pull/4804))
- Removed the border-radius() function and replaced any instances with tokens ([#4793](https://github.com/Shopify/polaris-react/pull/4793))
- Removed the shadow() function (replaced any instances with tokens) and renamed shadow legacy tokens ([#4823](https://github.com/Shopify/polaris-react/pull/4823))

Expand Down
8 changes: 4 additions & 4 deletions examples/cdn-styles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<body>
<div
style="
--top-bar-background: #00848e;
--top-bar-background-lighter: #1d9ba4;
--top-bar-color: #f9fafb;
--p-frame-offset: 0px;
--pc-top-bar-background: #00848e;
--pc-top-bar-background-lighter: #1d9ba4;
--pc-top-bar-color: #f9fafb;
--pc-frame-offset: 0px;
"
>
<div class="Polaris-Page">
Expand Down
2 changes: 2 additions & 0 deletions loom.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import type {} from '@shopify/loom-plugin-jest';
// eslint-disable-next-line import/no-default-export
export default createPackage((pkg) => {
pkg.entry({root: './src/index.ts'});
pkg.entry({name: 'token-list', root: './src/token-list.ts'});
pkg.use(
buildLibrary({
rootEntrypoints: false,
Copy link
Member

@BPScott BPScott Dec 8, 2021

Choose a reason for hiding this comment

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

As discussed, we should spin setting rootEntrypoints: false and removing the references to root level index.* files in the various ignore files (as rootEntrypoints: false means those files no longer gets generated) into a separate PR that targets main.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sound good 👍 I created this issue for tracking #4807

jestTestEnvironment: 'jsdom',
targets: 'extends @shopify/browserslist-config, node 12.20',
commonjs: true,
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"postcss-loader": "^4.2.0",
"postcss-modules": "^4.2.2",
"postcss-pxtorem": "^5.1.1",
"postcss-value-parser": "^4.2.0",
"prettier": "^2.5.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand All @@ -158,11 +159,6 @@
"ios >= 13.4"
],
"prettier": "@shopify/prettier-config",
"stylelint": {
"extends": [
"@shopify/stylelint-plugin/prettier"
]
},
"size-limit": [
{
"name": "cjs",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Breadcrumbs/Breadcrumbs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
width: var(--pc-breadcrumbs-icon-size);
height: var(--pc-breadcrumbs-icon-size);
margin: calc(-0.5 * var(--pc-breadcrumbs-icon-size)) 0
calc(-0.5 * var(--pc-breadcrumbs-icon-size)) calc(-1 * var(--p-space2));
calc(-0.5 * var(--pc-breadcrumbs-icon-size)) calc(-1 * var(--p-space-2));
margin: 0;
}
2 changes: 1 addition & 1 deletion src/components/CheckableButton/CheckableButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $button-vertical-padding: ($button-min-height - line-height(body) - 2px) / 2;
border-radius: var(--p-border-radius-1);
width: 100%;
background: var(--p-surface);
box-shadow: var(--p-button-drop-shadow);
box-shadow: var(--p-shadow-button);
border: 1px solid var(--p-border-neutral-subdued);
border-top-color: var(--p-border-subdued);
border-bottom-color: var(--p-border-shadow-subdued);
Expand Down
28 changes: 14 additions & 14 deletions src/components/Frame/Frame.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
}

@include frame-when-nav-displayed {
width: calc(100% - var(--p-frame-offset));
margin-left: var(--p-frame-offset);
width: calc(100% - var(--pc-frame-offset));
margin-left: var(--pc-frame-offset);
}
}

Expand All @@ -32,7 +32,7 @@

@include frame-when-nav-displayed {
z-index: 1;
left: var(--p-frame-offset);
left: var(--pc-frame-offset);
display: flex;

.hasTopBar & {
Expand Down Expand Up @@ -126,8 +126,8 @@
height: top-bar-height();

@include frame-when-nav-displayed {
left: var(--p-frame-offset);
width: calc(100% - var(--p-frame-offset));
left: var(--pc-frame-offset);
width: calc(100% - var(--pc-frame-offset));
}
}

Expand All @@ -139,8 +139,8 @@
width: 100%;

@include frame-when-nav-displayed {
left: var(--p-frame-offset);
width: calc(100% - var(--p-frame-offset));
left: var(--pc-frame-offset);
width: calc(100% - var(--pc-frame-offset));
}
}

Expand Down Expand Up @@ -175,7 +175,7 @@

.Content {
position: relative;
padding-bottom: var(--global-ribbon-height, 0);
padding-bottom: var(--pc-frame-global-ribbon-height, 0);
flex: 1;
@include layout-flex-fix;
}
Expand All @@ -187,16 +187,16 @@
width: 100%;

@include frame-when-nav-displayed {
left: var(--p-frame-offset);
left: var(--pc-frame-offset);

.hasNav & {
left: calc(#{layout-width(nav)} + var(--p-frame-offset));
left: calc(#{layout-width(nav)} + var(--pc-frame-offset));
@include safe-area-for(
left,
calc(#{layout-width(nav)} + var(--p-frame-offset)),
calc(#{layout-width(nav)} + var(--pc-frame-offset)),
left
);
width: calc(100% - #{layout-width(nav)} - var(--p-frame-offset));
width: calc(100% - #{layout-width(nav)} - var(--pc-frame-offset));
}
}
}
Expand All @@ -211,7 +211,7 @@

@include frame-when-nav-displayed {
.hasNav & {
left: var(--p-frame-offset);
left: var(--pc-frame-offset);
}

.hasTopBar & {
Expand All @@ -225,7 +225,7 @@
position: fixed;
z-index: var(--p-z-9);
top: var(--pc-frame-skip-vertical-offset);
left: calc(var(--p-space-2) + var(--p-frame-offset));
left: calc(var(--p-space-2) + var(--pc-frame-offset));
opacity: 0;
pointer-events: none;

Expand Down
10 changes: 5 additions & 5 deletions src/components/Frame/Frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ interface State {
showContextualSaveBar: boolean;
}

const GLOBAL_RIBBON_CUSTOM_PROPERTY = '--global-ribbon-height';
const FRAME_OFFSET_CUSTOM_PROPERTY = '--p-frame-offset';

const APP_FRAME_MAIN = 'AppFrameMain';
const APP_FRAME_NAV = 'AppFrameNav';
const APP_FRAME_TOP_BAR = 'AppFrameTopBar';
Expand Down Expand Up @@ -306,12 +303,15 @@ class FrameInner extends PureComponent<CombinedProps, State> {

private setOffset = () => {
const {offset = '0px'} = this.props;
setRootProperty(FRAME_OFFSET_CUSTOM_PROPERTY, offset);
setRootProperty('--pc-frame-offset', offset);
};

private setGlobalRibbonRootProperty = () => {
const {globalRibbonHeight} = this.state;
setRootProperty(GLOBAL_RIBBON_CUSTOM_PROPERTY, `${globalRibbonHeight}px`);
setRootProperty(
'--pc-frame-global-ribbon-height',
`${globalRibbonHeight}px`,
);
};

private showToast = (toast: ToastPropsWithID) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
right: 0;
left: 0;
text-align: center;
bottom: var(--global-ribbon-height);
bottom: var(--pc-frame-global-ribbon-height);
display: flex;
flex-direction: column;
align-items: center;
Expand Down
14 changes: 7 additions & 7 deletions src/components/Frame/tests/Frame.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ describe('<Frame />', () => {
mountWithApp(<Frame />);

expect(
document.documentElement.style.getPropertyValue('--p-frame-offset'),
document.documentElement.style.getPropertyValue('--pc-frame-offset'),
).toBe('0px');
});

it('renders a custom offset property when offset is passed', () => {
mountWithApp(<Frame offset="6rem" />);

expect(
document.documentElement.style.getPropertyValue('--p-frame-offset'),
document.documentElement.style.getPropertyValue('--pc-frame-offset'),
).toBe('6rem');
});

Expand Down Expand Up @@ -269,7 +269,7 @@ describe('<Frame />', () => {
});

describe('globalRibbon', () => {
// Frame sets the --global-ribbon-height custom property based off the
// Frame sets the --pc-frame-global-ribbon-height custom property based off the
// offsetHeight of the component passed into globalRibbon. JSDom doesn't
// have a layout engine so use a mock value
beforeEach(() => {
Expand All @@ -284,7 +284,7 @@ describe('<Frame />', () => {
mountWithApp(<Frame globalRibbon={<div />}>I am some content</Frame>);
expect(
document.documentElement.style.getPropertyValue(
'--global-ribbon-height',
'--pc-frame-global-ribbon-height',
),
).toBe('30px');
});
Expand All @@ -294,14 +294,14 @@ describe('<Frame />', () => {

expect(
document.documentElement.style.getPropertyValue(
'--global-ribbon-height',
'--pc-frame-global-ribbon-height',
),
).toBe('0px');

frame.setProps({globalRibbon: <div />});
expect(
document.documentElement.style.getPropertyValue(
'--global-ribbon-height',
'--pc-frame-global-ribbon-height',
),
).toBe('30px');
});
Expand All @@ -310,7 +310,7 @@ describe('<Frame />', () => {
mountWithApp(<Frame />);
expect(
document.documentElement.style.getPropertyValue(
'--global-ribbon-height',
'--pc-frame-global-ribbon-height',
),
).toBe('0px');
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/IndexTable/IndexTable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ $loading-panel-height: 53px;
}

.TableCell-first + .TableCell {
left: var(--p-checkbox-offset);
left: var(--pc-checkbox-offset);
padding-left: 0;

@include breakpoint-after($breakpoint-small) {
Expand Down Expand Up @@ -523,5 +523,5 @@ $scroll-bar-size: var(--p-space-2);

.ScrollBarContent {
height: 1px;
width: var(--p-scroll-bar-content-width);
width: var(--pc-index-table-scroll-bar-content-width);
}
4 changes: 2 additions & 2 deletions src/components/IndexTable/IndexTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function IndexTableBase({
const resizeTableScrollBar = useCallback(() => {
if (scrollBarElement.current && tableElement.current && tableInitialized) {
scrollBarElement.current.style.setProperty(
'--p-scroll-bar-content-width',
'--pc-index-table-scroll-bar-content-width',
`${tableElement.current.offsetWidth - SCROLL_BAR_PADDING}px`,
);
}
Expand Down Expand Up @@ -240,7 +240,7 @@ function IndexTableBase({
const handleResize = useCallback(() => {
// hide the scrollbar when resizing
scrollBarElement.current?.style.setProperty(
'--p-scroll-bar-content-width',
'--pc-index-table-scroll-bar-content-width',
`0px`,
);

Expand Down
2 changes: 1 addition & 1 deletion src/components/IndexTable/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function CheckboxWrapper({children}: CheckboxWrapperProps) {
if (!checkboxNode.current) return;

const {width} = checkboxNode.current.getBoundingClientRect();
setRootProperty('--p-checkbox-offset', `${width}px`);
setRootProperty('--pc-checkbox-offset', `${width}px`);
}, []);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,22 @@ describe('<Checkbox />', () => {
expect(checkbox).toContainReactComponent(CheckboxWrapper);
});

it('sets `--p-checkbox-offset` custom property', () => {
it('sets `--pc-checkbox-offset` custom property', () => {
mountWithTable(<Checkbox />, defaultTableProps);

expect(setRootPropertySpy).toHaveBeenLastCalledWith(
'--p-checkbox-offset',
'--pc-checkbox-offset',
'0px',
);
});

it('updates `--p-checkbox-offset` custom property on resize', () => {
it('updates `--pc-checkbox-offset` custom property on resize', () => {
mountWithTable(<Checkbox />, defaultTableProps);
setGetBoundingClientRect(200);
window.dispatchEvent(new Event('resize'));

expect(setRootPropertySpy).toHaveBeenLastCalledWith(
'--p-checkbox-offset',
'--pc-checkbox-offset',
'200px',
);
});
Expand Down
Loading