@adamjanicki/ui 1.0.1 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
- type BuiltinLinkProps = Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "href" | "onClick">;
3
- export type CustomLinkElement = (props: Partial<BuiltinLinkProps & {
2
+ type BuiltinLinkProps = Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "href">;
3
+ export type CustomLinkElement = (props: Partial<BuiltinLinkProps> & {
4
4
  to: string;
5
- }> & {
6
- ref?: React.Ref<HTMLAnchorElement>;
5
+ } & {
6
+ ref?: React.MutableRefObject<HTMLAnchorElement>;
7
7
  }) => React.ReactNode;
8
8
  type DefaultLinkProps = BuiltinLinkProps & {
9
9
  /**
@@ -18,4 +18,5 @@ type DefaultLinkProps = BuiltinLinkProps & {
18
18
  LinkElement?: CustomLinkElement;
19
19
  };
20
20
  export declare const UnstyledLink: React.ForwardRefExoticComponent<Omit<DefaultLinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
21
- export {};
21
+ declare const Link: React.ForwardRefExoticComponent<Omit<DefaultLinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
22
+ export default Link;
@@ -22,6 +22,7 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  };
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
24
24
  import { forwardRef } from "react";
25
+ import { classNames } from "../../utils/util";
25
26
  var DefaultLinkElement = forwardRef(function (_a, ref) {
26
27
  var to = _a.to, props = __rest(_a, ["to"]);
27
28
  return _jsx("a", __assign({}, props, { href: to, ref: ref }));
@@ -30,3 +31,8 @@ export var UnstyledLink = forwardRef(function (_a, ref) {
30
31
  var _b = _a.LinkElement, LinkElement = _b === void 0 ? DefaultLinkElement : _b, props = __rest(_a, ["LinkElement"]);
31
32
  return (_jsx(LinkElement, __assign({}, props, { ref: ref })));
32
33
  });
34
+ var Link = forwardRef(function (_a, ref) {
35
+ var className = _a.className, props = __rest(_a, ["className"]);
36
+ return (_jsx(UnstyledLink, __assign({}, props, { className: classNames("ajui-link-default", className), ref: ref })));
37
+ });
38
+ export default Link;
@@ -1 +1,3 @@
1
+ import Link from "./Link";
2
+ export default Link;
1
3
  export * from "./Link";
@@ -1 +1,3 @@
1
+ import Link from "./Link";
2
+ export default Link;
1
3
  export * from "./Link";
package/hooks/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export { default as useScrollLock } from "./useScrollLock";
2
2
  export { default as useMediaQuery } from "./useMediaQuery";
3
3
  export { default as useWatchScroll } from "./useWatchScroll";
4
4
  export { default as useFocusTrap } from "./useFocusTrap";
5
+ export { default as useScrollToHash } from "./useScrollToHash";
package/hooks/index.js CHANGED
@@ -2,3 +2,4 @@ export { default as useScrollLock } from "./useScrollLock";
2
2
  export { default as useMediaQuery } from "./useMediaQuery";
3
3
  export { default as useWatchScroll } from "./useWatchScroll";
4
4
  export { default as useFocusTrap } from "./useFocusTrap";
5
+ export { default as useScrollToHash } from "./useScrollToHash";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A hook for scrolling to a hash on the page.
3
+ * @returns a function that scrolls to the hash on the page
4
+ */
5
+ declare const useScrollToHash: () => (behavior?: ScrollBehavior) => void;
6
+ export default useScrollToHash;
@@ -0,0 +1,22 @@
1
+ import { useCallback } from "react";
2
+ /**
3
+ * A hook for scrolling to a hash on the page.
4
+ * @returns a function that scrolls to the hash on the page
5
+ */
6
+ var useScrollToHash = function () {
7
+ return useCallback(
8
+ /**
9
+ * Scrolls to the hash on the page.
10
+ * @param behavior the behavior of the scroll
11
+ */
12
+ function (behavior) {
13
+ var hash = window.location.hash;
14
+ if (hash) {
15
+ var element = document.getElementById(hash.substring(1));
16
+ if (element) {
17
+ element.scrollIntoView({ behavior: behavior });
18
+ }
19
+ }
20
+ }, []);
21
+ };
22
+ export default useScrollToHash;
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./components/Button";
2
2
  export { default as Button } from "./components/Button";
3
3
  export * from "./components/Link";
4
+ export { default as Link } from "./components/Link";
4
5
  export * from "./components/Input";
5
6
  export { default as Input } from "./components/Input";
6
7
  export { default as Alert } from "./components/Alert";
package/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  export * from "./components/Button";
3
3
  export { default as Button } from "./components/Button";
4
4
  export * from "./components/Link";
5
+ export { default as Link } from "./components/Link";
5
6
  export * from "./components/Input";
6
7
  export { default as Input } from "./components/Input";
7
8
  export { default as Alert } from "./components/Alert";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamjanicki/ui",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "Basic UI components and hooks for React in TypeScript",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -28,24 +28,17 @@
28
28
  "@types/jest": "^29.5.8",
29
29
  "@typescript-eslint/eslint-plugin": "^6.11.0",
30
30
  "@typescript-eslint/parser": "^6.11.0",
31
- "css-loader": "^7.1.2",
32
31
  "eslint": "^8.53.0",
33
32
  "eslint-config-prettier": "^9.0.0",
34
33
  "eslint-plugin-react": "^7.33.2",
35
34
  "eslint-plugin-react-hooks": "^4.6.0",
36
- "identity-obj-proxy": "^3.0.0",
37
35
  "jest": "^29.7.0",
38
36
  "jest-canvas-mock": "^2.5.2",
39
37
  "jest-css-modules": "^2.1.0",
40
38
  "jest-environment-jsdom": "^29.7.0",
41
- "mini-css-extract-plugin": "^2.9.0",
42
39
  "nodemon": "^3.1.4",
43
- "style-loader": "^4.0.0",
44
40
  "ts-jest": "^29.2.2",
45
- "ts-loader": "^9.5.1",
46
- "typescript": "^5.2.2",
47
- "webpack": "^5.93.0",
48
- "webpack-cli": "^5.1.4"
41
+ "typescript": "^5.2.2"
49
42
  },
50
43
  "eslintConfig": {
51
44
  "extends": [
package/style.css CHANGED
@@ -52,6 +52,8 @@
52
52
  --ajui-static-border: #bdbdbd;
53
53
  /* Modal */
54
54
  --ajui-modal-backdrop-background: rgba(0, 0, 0, 0.5);
55
+ /* Link */
56
+ --ajui-link-color: #0070ff;
55
57
  }
56
58
 
57
59
  a:not([disabled]):is(:focus-visible),
@@ -181,9 +183,15 @@ a {
181
183
  background-color: var(--ajui-button-secondary-background);
182
184
  }
183
185
 
186
+ .ajui-link-default {
187
+ color: var(--ajui-link-color);
188
+ transition: opacity var(--ajui-default-transition);
189
+ }
190
+
184
191
  @media (hover: hover) {
185
192
  .ajui-button--primary:not([disabled]):hover,
186
- .ajui-icon-button:not([disabled]):hover {
193
+ .ajui-icon-button:not([disabled]):hover,
194
+ .ajui-link-default:hover {
187
195
  opacity: var(--ajui-default-opacity-dim);
188
196
  }
189
197
 
package/sandbox/README.md DELETED
@@ -1 +0,0 @@
1
- # Sandbox
@@ -1,43 +0,0 @@
1
- {
2
- "name": "sandbox",
3
- "version": "0.1.0",
4
- "homepage": "https://adamjanicki2.github.io/sandbox",
5
- "private": true,
6
- "dependencies": {
7
- "@adamjanicki/core-ui": "^1.0.4",
8
- "react": ">=18",
9
- "react-dom": ">=18",
10
- "react-scripts": "5.0.1",
11
- "tachyons": "^4.12.0",
12
- "typescript": "^4.9.5"
13
- },
14
- "scripts": {
15
- "start": "react-scripts start",
16
- "build": "GENERATE_SOURCEMAP=false react-scripts build; cp build/index.html build/404.html",
17
- "predeploy": "npm run build",
18
- "deploy": "gh-pages -d build"
19
- },
20
- "eslintConfig": {
21
- "extends": [
22
- "react-app"
23
- ]
24
- },
25
- "browserslist": {
26
- "production": [
27
- ">0.2%",
28
- "not dead",
29
- "not op_mini all"
30
- ],
31
- "development": [
32
- "last 1 chrome version",
33
- "last 1 firefox version",
34
- "last 1 safari version"
35
- ]
36
- },
37
- "devDependencies": {
38
- "@types/node": "^20.6.2",
39
- "@types/react": "^18.2.22",
40
- "@types/react-dom": "^18.2.7",
41
- "gh-pages": "^6.0.0"
42
- }
43
- }
Binary file
@@ -1,21 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <link
6
- rel="icon"
7
- href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🏖️</text></svg>"
8
- />
9
- <meta name="viewport" content="width=device-width, initial-scale=1" />
10
- <meta name="theme-color" content="#000000" />
11
- <meta name="description" content="Site built from React Skeleton" />
12
- <meta name="og:title" content="Sandbox" />
13
- <meta name="og:image" content="%PUBLIC_URL%/og-image.png" />
14
- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
15
- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
16
- <title>Sandbox</title>
17
- </head>
18
- <body>
19
- <div id="root"></div>
20
- </body>
21
- </html>
Binary file
Binary file
@@ -1,24 +0,0 @@
1
- {
2
- "name": "Sandbox",
3
- "icons": [
4
- {
5
- "src": "favicon.ico",
6
- "sizes": "64x64 32x32 24x24 16x16",
7
- "type": "image/x-icon"
8
- },
9
- {
10
- "src": "logo192.png",
11
- "type": "image/png",
12
- "sizes": "192x192"
13
- },
14
- {
15
- "src": "logo512.png",
16
- "type": "image/png",
17
- "sizes": "512x512"
18
- }
19
- ],
20
- "start_url": ".",
21
- "display": "standalone",
22
- "theme_color": "#000000",
23
- "background_color": "#ffffff"
24
- }
Binary file