-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8719701
commit 6cf8ed6
Showing
23 changed files
with
325 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "@star4/dom", | ||
"version": "0.0.1", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/tmol4/star4.git", | ||
"directory": "packages/dom" | ||
}, | ||
"homepage": "https://tmol4.github.io/star4", | ||
"files": [ | ||
"dist/**/*" | ||
], | ||
"type": "module", | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"browser": {}, | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/index.d.cts", | ||
"default": "./dist/index.cjs" | ||
} | ||
} | ||
}, | ||
"typesVersions": {}, | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
"build": "tsup", | ||
"dev": "tsup --watch", | ||
"publish": "yarn npm publish" | ||
}, | ||
"devDependencies": { | ||
"@star4/config": "workspace:^", | ||
"@types/node": "^22.8.6", | ||
"tsup": "^8.3.5", | ||
"typescript": "^5.6.3" | ||
}, | ||
"dependencies": { | ||
"@floating-ui/dom": "^1.6.12", | ||
"clsx": "^2.1.1" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": [ | ||
"@star4/config/tsconfig/module", | ||
"@star4/config/tsconfig/web", | ||
"@star4/config/tsconfig/strict", | ||
], | ||
"include": ["src", "tsup.config.ts"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { defineConfig, type Options } from "tsup"; | ||
|
||
export default defineConfig(config => { | ||
const watching = !!config.watch; | ||
return { | ||
target: "esnext", | ||
platform: "browser", | ||
format: watching ? "esm" : ["esm", "cjs"], | ||
clean: !watching, // && i === 0 (for the first config) | ||
dts: true, | ||
entry: ["src/index.ts"], | ||
outDir: "dist", | ||
treeshake: watching ? false : { preset: "safest" }, | ||
bundle: true, | ||
minify: !watching, | ||
replaceNodeEnv: true, | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# @star4/react-utils | ||
|
||
## 0.0.2 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies | ||
- @star4/vanilla-extract@0.0.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "@star4/react-utils", | ||
"version": "0.0.2", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/tmol4/star4.git", | ||
"directory": "packages/react-utils" | ||
}, | ||
"homepage": "https://tmol4.github.io/star4", | ||
"files": [ | ||
"dist/**/*" | ||
], | ||
"type": "module", | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"browser": {}, | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/index.d.cts", | ||
"default": "./dist/index.cjs" | ||
} | ||
} | ||
}, | ||
"typesVersions": {}, | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
"build": "tsup", | ||
"dev": "tsup --watch", | ||
"publish": "yarn npm publish" | ||
}, | ||
"devDependencies": { | ||
"@star4/config": "workspace:^", | ||
"@types/node": "^22.8.6", | ||
"@types/react": "^18.3.12", | ||
"@types/react-dom": "^18.3.1", | ||
"tsup": "^8.3.5", | ||
"typescript": "^5.6.3" | ||
}, | ||
"dependencies": { | ||
"@floating-ui/dom": "^1.6.12", | ||
"@star4/vanilla-extract": "workspace:^", | ||
"clsx": "^2.1.1", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./is-server"; | ||
export * from "./use-isomorphic-layout-effect"; | ||
export * from "./use-media-query"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const IS_SERVER = typeof window === "undefined"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { useEffect, useLayoutEffect } from "react"; | ||
import { IS_SERVER } from "./is-server"; | ||
|
||
export const useIsomorphicLayoutEffect = | ||
IS_SERVER ? useEffect : useLayoutEffect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { useEffect, useState } from "react"; | ||
import { IS_SERVER } from "./is-server"; | ||
|
||
export const useMediaQuery = (query: string, serverFallback = false): boolean => { | ||
if (IS_SERVER) { | ||
return serverFallback; | ||
} | ||
|
||
const initialValue = window.matchMedia(query).matches; | ||
const [matches, setMatches] = useState(initialValue); | ||
|
||
useEffect( | ||
() => { | ||
const media = window.matchMedia(query); | ||
const update = () => setMatches(media.matches); | ||
media.addEventListener("change", update); | ||
return media.removeEventListener.bind(media, "change", update) | ||
}, | ||
[query], | ||
); | ||
|
||
return matches; | ||
} | ||
|
||
type MediaFeatures = { | ||
"any-hover": "none" | "hover"; | ||
"any-pointer": "none" | "coarse" | "fine"; | ||
"aspect-ratio": ""; | ||
"color": ""; | ||
"color-gamut": ""; | ||
"color-index": ""; | ||
"device-aspect-ratio Deprecated": ""; | ||
"device-height Deprecated": ""; | ||
"device-width Deprecated": ""; | ||
"display-mode": ""; | ||
"dynamic-range": ""; | ||
"forced-colors": "none" | "active"; | ||
"grid": ""; | ||
"height": ""; | ||
"hover": "none" | "hover"; | ||
"inverted-colors": "none" | "inverted"; | ||
"monochrome": ""; | ||
"orientation": "portrait" | "landscape"; | ||
"overflow-block": ""; | ||
"overflow-inline": ""; | ||
"pointer": ""; | ||
"prefers-color-scheme": ""; | ||
"prefers-contrast": ""; | ||
"prefers-reduced-motion": ""; | ||
"prefers-reduced-transparency": ""; | ||
"resolution": ""; | ||
"scripting": ""; | ||
"update": ""; | ||
"video-dynamic-range": ""; | ||
"width": ""; | ||
} | ||
|
||
|
||
// export const usePrefersDark = (serverFallback?: boolean) => { | ||
// return useMediaQuery("(prefers-color-scheme: dark)", serverFallback); | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": [ | ||
"@star4/config/tsconfig/module", | ||
"@star4/config/tsconfig/web", | ||
"@star4/config/tsconfig/strict", | ||
], | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
}, | ||
"include": ["src", "tsup.config.ts"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { defineConfig, type Options } from "tsup"; | ||
|
||
export default defineConfig(config => { | ||
const watching = !!config.watch; | ||
return { | ||
target: "esnext", | ||
platform: "browser", | ||
format: watching ? "esm" : ["esm", "cjs"], | ||
clean: !watching, // && i === 0 (for the first config) | ||
dts: true, | ||
entry: ["src/index.ts"], | ||
outDir: "dist", | ||
treeshake: watching ? false : { preset: "safest" }, | ||
bundle: true, | ||
minify: !watching, | ||
replaceNodeEnv: true, | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.