Skip to content

Commit da8aa98

Browse files
Merge pull request #7 from glints-dev/feature/port-pop-over
feat: remove Popover dependencies on AppProvider
2 parents c84b78c + 422cd30 commit da8aa98

File tree

6 files changed

+34
-77
lines changed

6 files changed

+34
-77
lines changed

.changeset/sweet-books-sip.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'polaris-glints': major
3+
---
4+
5+
remove app-provider deps frm popover

.github/workflows/ci-a11y-vrt.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ on:
66
- main
77
- next
88
paths:
9-
- 'polaris-react/src/**'
10-
- 'polaris-react/playground/**'
11-
- 'polaris-tokens/src/**'
9+
- "polaris-react/src/**"
10+
- "polaris-react/playground/**"
11+
- "polaris-tokens/src/**"
1212
pull_request:
1313
paths:
14-
- 'polaris-react/src/**'
15-
- 'polaris-react/playground/**'
16-
- 'polaris-tokens/src/**'
14+
- "polaris-react/src/**"
15+
- "polaris-react/playground/**"
16+
- "polaris-tokens/src/**"
1717

1818
jobs:
1919
accessibility_test:
20-
name: 'Accessibility test'
20+
name: "Accessibility test"
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Checkout branch
@@ -56,15 +56,9 @@ jobs:
5656
run: yarn turbo run build --filter=@shopify/polaris
5757

5858
- name: Build Storybook
59-
run: yarn workspace @shopify/polaris run storybook:build --quiet
60-
61-
- name: Run accessibility test
62-
run: node ./polaris-react/scripts/accessibility-check.js
63-
env:
64-
STORYBOOK_DISABLE_DOCS: 1
59+
run: yarn workspace polaris-glints run storybook:build --quiet
6560

66-
visual_regression_test:
67-
name: 'Visual regression test'
61+
name: "Visual regression test"
6862
runs-on: ubuntu-latest
6963
steps:
7064
- name: Checkout branch
@@ -103,8 +97,8 @@ jobs:
10397
with:
10498
token: ${{ secrets.GITHUB_TOKEN }}
10599
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
106-
autoAcceptChanges: 'main'
107-
storybookBuildDir: 'polaris-react/build-internal/storybook/static'
100+
autoAcceptChanges: "main"
101+
storybookBuildDir: "polaris-react/build-internal/storybook/static"
108102
exitZeroOnChanges: true
109103
exitOnceUploaded: true
110104
env:

polaris-react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"@types/react": "*",
6868
"@types/react-dom": "*",
6969
"@types/react-transition-group": "^4.4.2",
70+
"nanoid": "^4.0.0",
7071
"react-fast-compare": "^3.2.0",
7172
"react-transition-group": "^4.4.2"
7273
},

polaris-react/src/components/Popover/Popover.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import React, {
88
useState,
99
} from 'react';
1010
import type {AriaAttributes} from 'react';
11+
import {nanoid} from 'nanoid';
1112

1213
import {
1314
findFirstFocusableNodeIncludingDisabled,
1415
focusNextFocusableNode,
1516
} from '../../utilities/focus';
1617
import {Portal} from '../Portal';
1718
import {portal} from '../shared';
18-
import {useUniqueId} from '../../utilities/unique-id';
1919

2020
import {
2121
PopoverCloseSource,
@@ -117,7 +117,7 @@ const PopoverComponent = forwardRef<PopoverPublicAPI, PopoverProps>(
117117
const activatorContainer = useRef<HTMLElement>(null);
118118

119119
const WrapperComponent: any = activatorWrapper;
120-
const id = useUniqueId('popover');
120+
const id = `popover-${nanoid()}`;
121121

122122
function forceUpdatePosition() {
123123
overlayRef.current?.forceUpdatePosition();

polaris-react/src/components/Portal/Portal.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React, {useEffect} from 'react';
22
import {createPortal} from 'react-dom';
3-
4-
import {usePortalsManager} from '../../utilities/portals';
5-
import {useUniqueId} from '../../utilities/unique-id';
3+
import {nanoid} from 'nanoid';
64

75
export interface PortalProps {
86
children?: React.ReactNode;
@@ -15,9 +13,13 @@ export function Portal({
1513
idPrefix = '',
1614
onPortalCreated = noop,
1715
}: PortalProps) {
18-
const {container} = usePortalsManager();
19-
20-
const uniqueId = useUniqueId('portal');
16+
const container = document.getElementById('glints-portal-container');
17+
if (!container) {
18+
throw new Error(
19+
'No element with id `glints-portal-container` found, please add it outside where the root app is rendered',
20+
);
21+
}
22+
const uniqueId = `portal-${nanoid()}`;
2123
const portalId = idPrefix !== '' ? `${idPrefix}-${uniqueId}` : uniqueId;
2224

2325
useEffect(() => {

yarn.lock

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4106,11 +4106,6 @@
41064106
resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
41074107
integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==
41084108

4109-
"@yarnpkg/lockfile@^1.1.0":
4110-
version "1.1.0"
4111-
resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
4112-
integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==
4113-
41144109
abab@^2.0.3, abab@^2.0.5:
41154110
version "2.0.6"
41164111
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.6.tgz#41b80f2c871d19686216b82309231cfd3cb3d291"
@@ -5499,7 +5494,7 @@ ccount@^1.0.0:
54995494
resolved "https://registry.yarnpkg.com/ccount/-/ccount-1.1.0.tgz#246687debb6014735131be8abab2d93898f8d043"
55005495
integrity sha512-vlNK021QdI7PNeiUh/lKkC/mNHHfV0m/Ad5JoI0TYtlBnJAslM/JIkm/tGC88bkLIwO6OQ5uV6ztS6kVAtCDlg==
55015496

5502-
chalk@^2.0.0, chalk@^2.1.0, chalk@^2.4.1, chalk@^2.4.2:
5497+
chalk@^2.0.0, chalk@^2.1.0, chalk@^2.4.1:
55035498
version "2.4.2"
55045499
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
55055500
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
@@ -5647,11 +5642,6 @@ chrome-trace-event@^1.0.2:
56475642
resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac"
56485643
integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==
56495644

5650-
ci-info@^2.0.0:
5651-
version "2.0.0"
5652-
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46"
5653-
integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==
5654-
56555645
ci-info@^3.1.0:
56565646
version "3.3.1"
56575647
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.3.1.tgz#58331f6f472a25fe3a50a351ae3052936c2c7f32"
@@ -8087,13 +8077,6 @@ find-yarn-workspace-root2@1.2.16:
80878077
micromatch "^4.0.2"
80888078
pkg-dir "^4.2.0"
80898079

8090-
find-yarn-workspace-root@^2.0.0:
8091-
version "2.0.0"
8092-
resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd"
8093-
integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==
8094-
dependencies:
8095-
micromatch "^4.0.2"
8096-
80978080
flat-cache@^3.0.4:
80988081
version "3.0.4"
80998082
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11"
@@ -9455,13 +9438,6 @@ is-callable@^1.1.4, is-callable@^1.2.4:
94559438
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.4.tgz#47301d58dd0259407865547853df6d61fe471945"
94569439
integrity sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==
94579440

9458-
is-ci@^2.0.0:
9459-
version "2.0.0"
9460-
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c"
9461-
integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==
9462-
dependencies:
9463-
ci-info "^2.0.0"
9464-
94659441
is-ci@^3.0.1:
94669442
version "3.0.1"
94679443
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-3.0.1.tgz#db6ecbed1bd659c43dac0f45661e7674103d1867"
@@ -10683,13 +10659,6 @@ kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3:
1068310659
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
1068410660
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==
1068510661

10686-
klaw-sync@^6.0.0:
10687-
version "6.0.0"
10688-
resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"
10689-
integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==
10690-
dependencies:
10691-
graceful-fs "^4.1.11"
10692-
1069310662
klaw@^1.0.0:
1069410663
version "1.3.1"
1069510664
resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439"
@@ -11740,6 +11709,11 @@ nanoid@^3.3.4:
1174011709
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"
1174111710
integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==
1174211711

11712+
nanoid@^4.0.0:
11713+
version "4.0.0"
11714+
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-4.0.0.tgz#6e144dee117609232c3f415c34b0e550e64999a5"
11715+
integrity sha512-IgBP8piMxe/gf73RTQx7hmnhwz0aaEXYakvqZyE302IXW3HyVNhdNGC+O2MwMAVhLEnvXlvKtGbtJf6wvHihCg==
11716+
1174311717
nanomatch@^1.2.9:
1174411718
version "1.2.13"
1174511719
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
@@ -12228,7 +12202,7 @@ only@~0.0.2:
1222812202
resolved "https://registry.yarnpkg.com/only/-/only-0.0.2.tgz#2afde84d03e50b9a8edc444e30610a70295edfb4"
1222912203
integrity sha512-Fvw+Jemq5fjjyWz6CpKx6w9s7xxqo3+JCyM0WXWeCSOboZ8ABkyvP8ID4CZuChA/wxSx+XSJmdOm8rGVyJ1hdQ==
1223012204

12231-
open@^7.0.3, open@^7.4.2:
12205+
open@^7.0.3:
1223212206
version "7.4.2"
1223312207
resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321"
1223412208
integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==
@@ -12591,25 +12565,6 @@ password-prompt@^1.1.2:
1259112565
ansi-escapes "^3.1.0"
1259212566
cross-spawn "^6.0.5"
1259312567

12594-
patch-package@^6.4.7:
12595-
version "6.4.7"
12596-
resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.4.7.tgz#2282d53c397909a0d9ef92dae3fdeb558382b148"
12597-
integrity sha512-S0vh/ZEafZ17hbhgqdnpunKDfzHQibQizx9g8yEf5dcVk3KOflOfdufRXQX8CSEkyOQwuM/bNz1GwKvFj54kaQ==
12598-
dependencies:
12599-
"@yarnpkg/lockfile" "^1.1.0"
12600-
chalk "^2.4.2"
12601-
cross-spawn "^6.0.5"
12602-
find-yarn-workspace-root "^2.0.0"
12603-
fs-extra "^7.0.1"
12604-
is-ci "^2.0.0"
12605-
klaw-sync "^6.0.0"
12606-
minimist "^1.2.0"
12607-
open "^7.4.2"
12608-
rimraf "^2.6.3"
12609-
semver "^5.6.0"
12610-
slash "^2.0.0"
12611-
tmp "^0.0.33"
12612-
1261312568
path-browserify@0.0.1:
1261412569
version "0.0.1"
1261512570
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a"

0 commit comments

Comments
 (0)