Skip to content

Commit fd3bfd5

Browse files
committed
feat: higher order style
1 parent e45c677 commit fd3bfd5

File tree

5 files changed

+85
-15
lines changed

5 files changed

+85
-15
lines changed

inc/class/class-bootstrap.php

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,31 @@ public function __construct() {
2222
require_once __DIR__ . '/admin/index.php';
2323
require_once __DIR__ . '/front-end/index.php';
2424

25-
\add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_script' ), 99 );
26-
\add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_script' ), 99 );
25+
\add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_script' ), 99 );
26+
\add_action( 'wp_enqueue_scripts', array( $this, 'frontend_enqueue_script' ), 99 );
27+
}
28+
29+
/**
30+
* Admin Enqueue script
31+
* You can load the script on demand
32+
*
33+
* @param string $hook current page hook
34+
*
35+
* @return void
36+
*/
37+
public function admin_enqueue_script( $hook ): void {
38+
$this->enqueue_script();
39+
}
40+
41+
42+
/**
43+
* Front-end Enqueue script
44+
* You can load the script on demand
45+
*
46+
* @return void
47+
*/
48+
public function frontend_enqueue_script(): void {
49+
$this->enqueue_script();
2750
}
2851

2952
/**
@@ -33,17 +56,6 @@ public function __construct() {
3356
* @return void
3457
*/
3558
public function enqueue_script(): void {
36-
/*
37-
* enquene script on demand
38-
if (\is_admin()) {
39-
// match wp-admin screen_id
40-
$screen = \get_current_screen();
41-
if (($screen->id !== Plugin::KEBAB)) return;
42-
} else {
43-
// match front-end post_type slug {Plugin::KEBAB}
44-
if (strpos($_SERVER['REQUEST_URI'], Plugin::KEBAB) === false) return;
45-
}
46-
*/
4759

4860
Vite\enqueue_asset(
4961
Plugin::$dir . '/js/dist',

js/src/assets/scss/global.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ input[class*="ant-select"] {
1515
border: none !important;
1616
outline: none !important;
1717
}
18+
1819
input.ant-input {
1920
min-height: unset !important;
2021
line-height: 1.5 !important;

js/src/main.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom/client'
33
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
44
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
55
import { app1Selector, app2Selector } from '@/utils'
6+
import { StyleProvider } from '@ant-design/cssinjs'
67

78
const App1 = React.lazy(() => import('./App1'))
89
const App2 = React.lazy(() => import('./App2'))
@@ -36,7 +37,9 @@ mapping.forEach(({ els, App }) => {
3637
ReactDOM.createRoot(el).render(
3738
<React.StrictMode>
3839
<QueryClientProvider client={queryClient}>
39-
<App />
40+
<StyleProvider hashPriority="high">
41+
<App />
42+
</StyleProvider>
4043
<ReactQueryDevtools initialIsOpen={false} />
4144
</QueryClientProvider>
4245
</React.StrictMode>,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
},
3232
"devDependencies": {
3333
"@rollup/plugin-alias": "^5.1.0",
34+
"@ant-design/cssinjs": "^1.19.1",
3435
"@kucrut/vite-for-wp": "^0.8.0",
3536
"@soderlind/wp-project-version-sync": "^2.0.2",
3637
"@tanstack/react-query-devtools": "^5.28.10",

yarn.lock

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@
2020
"@jridgewell/gen-mapping" "^0.3.0"
2121
"@jridgewell/trace-mapping" "^0.3.9"
2222

23+
"@ant-design/cssinjs@^1.19.1":
24+
version "1.19.1"
25+
resolved "https://registry.yarnpkg.com/@ant-design/cssinjs/-/cssinjs-1.19.1.tgz#d3bb4f58ee884c9c757688e611e7a6de9867ea75"
26+
integrity sha512-hgQ3wiys3X0sqDKWkqCJ6EYdF79i9JCvtavmIGwuuPUKmoJXV8Ff0sY+yQQSxk2dRmMyam/bYKo/Bwor45hnZw==
27+
dependencies:
28+
"@babel/runtime" "^7.11.1"
29+
"@emotion/hash" "^0.8.0"
30+
"@emotion/unitless" "^0.7.5"
31+
classnames "^2.3.1"
32+
csstype "^3.1.3"
33+
rc-util "^5.35.0"
34+
stylis "^4.0.13"
35+
2336
"@augment-vir/common@^23.3.4":
2437
version "23.4.0"
2538
resolved "https://registry.yarnpkg.com/@augment-vir/common/-/common-23.4.0.tgz#8aa3930c86414899c273342cc22945a0dc128c64"
@@ -1659,6 +1672,13 @@
16591672
resolved "https://registry.yarnpkg.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310"
16601673
integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==
16611674

1675+
"@babel/runtime@^7.11.1", "@babel/runtime@^7.18.3":
1676+
version "7.24.1"
1677+
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.24.1.tgz#431f9a794d173b53720e69a6464abc6f0e2a5c57"
1678+
integrity sha512-+BIznRzyqBf+2wCTxcKE3wDjfGeCoVE61KSHGpkzqrLi8qxqFwBeUFyId2cxkTmm55fzDGnm0+yCxaxygrLUnQ==
1679+
dependencies:
1680+
regenerator-runtime "^0.14.0"
1681+
16621682
"@babel/runtime@^7.16.0", "@babel/runtime@^7.20.7", "@babel/runtime@^7.8.4":
16631683
version "7.23.1"
16641684
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.1.tgz#72741dc4d413338a91dcb044a86f3c0bc402646d"
@@ -1744,6 +1764,16 @@
17441764
resolved "https://registry.yarnpkg.com/@csstools/selector-specificity/-/selector-specificity-3.0.2.tgz#ea61ba7bb24be3502c6aaa3190ed231f4633a81e"
17451765
integrity sha512-RpHaZ1h9LE7aALeQXmXrJkRG84ZxIsctEN2biEUmFyKpzFM3zZ35eUMcIzZFsw/2olQE6v69+esEqU2f1MKycg==
17461766

1767+
"@emotion/hash@^0.8.0":
1768+
version "0.8.0"
1769+
resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.8.0.tgz#bbbff68978fefdbe68ccb533bc8cbe1d1afb5413"
1770+
integrity sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==
1771+
1772+
"@emotion/unitless@^0.7.5":
1773+
version "0.7.5"
1774+
resolved "https://registry.yarnpkg.com/@emotion/unitless/-/unitless-0.7.5.tgz#77211291c1900a700b8a78cfafda3160d76949ed"
1775+
integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg==
1776+
17471777
"@es-joy/jsdoccomment@~0.41.0":
17481778
version "0.41.0"
17491779
resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.41.0.tgz#4a2f7db42209c0425c71a1476ef1bdb6dcd836f6"
@@ -3740,6 +3770,11 @@ ci-info@^3.2.0:
37403770
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4"
37413771
integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==
37423772

3773+
classnames@^2.3.1:
3774+
version "2.5.1"
3775+
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.5.1.tgz#ba774c614be0f016da105c858e7159eae8e7687b"
3776+
integrity sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==
3777+
37433778
cli-boxes@^3.0.0:
37443779
version "3.0.0"
37453780
resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-3.0.0.tgz#71a10c716feeba005e4504f36329ef0b17cf3145"
@@ -3987,6 +4022,11 @@ csstype@^3.0.2:
39874022
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.2.tgz#1d4bf9d572f11c14031f0436e1c10bc1f571f50b"
39884023
integrity sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==
39894024

4025+
csstype@^3.1.3:
4026+
version "3.1.3"
4027+
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81"
4028+
integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==
4029+
39904030
damerau-levenshtein@^1.0.8:
39914031
version "1.0.8"
39924032
resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz#b43d286ccbd36bc5b2f7ed41caf2d0aba1f8a6e7"
@@ -7331,6 +7371,14 @@ quick-lru@^6.1.1:
73317371
resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-6.1.2.tgz#e9a90524108629be35287d0b864e7ad6ceb3659e"
73327372
integrity sha512-AAFUA5O1d83pIHEhJwWCq/RQcRukCkn/NSm2QsTEMle5f2hP0ChI2+3Xb051PZCkLryI/Ir1MVKviT2FIloaTQ==
73337373

7374+
rc-util@^5.35.0:
7375+
version "5.39.1"
7376+
resolved "https://registry.yarnpkg.com/rc-util/-/rc-util-5.39.1.tgz#7bca4fb55e20add0eef5c23166cd9f9e5f51a8a1"
7377+
integrity sha512-OW/ERynNDgNr4y0oiFmtes3rbEamXw7GHGbkbNd9iRr7kgT03T6fT0b9WpJ3mbxKhyOcAHnGcIoh5u/cjrC2OQ==
7378+
dependencies:
7379+
"@babel/runtime" "^7.18.3"
7380+
react-is "^18.2.0"
7381+
73347382
rc@1.2.8:
73357383
version "1.2.8"
73367384
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"
@@ -7354,7 +7402,7 @@ react-is@^16.13.1:
73547402
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
73557403
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
73567404

7357-
react-is@^18.0.0:
7405+
react-is@^18.0.0, react-is@^18.2.0:
73587406
version "18.2.0"
73597407
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
73607408
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==
@@ -8215,6 +8263,11 @@ strip-json-comments@~2.0.1:
82158263
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
82168264
integrity sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==
82178265

8266+
stylis@^4.0.13:
8267+
version "4.3.1"
8268+
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.3.1.tgz#ed8a9ebf9f76fe1e12d462f5cc3c4c980b23a7eb"
8269+
integrity sha512-EQepAV+wMsIaGVGX1RECzgrcqRRU/0sYOHkeLsZ3fzHaHXZy4DaOOX0vOlGQdlsjkh3mFHAIlVimpwAs4dslyQ==
8270+
82188271
sucrase@^3.32.0:
82198272
version "3.34.0"
82208273
resolved "https://registry.yarnpkg.com/sucrase/-/sucrase-3.34.0.tgz#1e0e2d8fcf07f8b9c3569067d92fbd8690fb576f"

0 commit comments

Comments
 (0)