react-headings 4.0.0-next.2 → 4.0.0-next.3

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.
package/README.md CHANGED
@@ -18,7 +18,7 @@ Hardcoded heading levels break accessibility and SEO when components are reused.
18
18
  ## Features
19
19
 
20
20
  - Supports server-side rendering
21
- - 370 bytes minified & brotlied
21
+ - Only 369 bytes minified & brotlied
22
22
  - Typed with TypeScript
23
23
  - Works with any CSS solution (Tailwind, CSS-in-JS, etc.)
24
24
  - Plays nicely with component libraries
@@ -31,37 +31,38 @@ npm install react-headings
31
31
 
32
32
  ## Usage
33
33
 
34
- Use `H` for every heading. Wrap the content that belongs under a heading in `HeadingLevel`: headings inside render one level deeper.
34
+ Use `Heading` for every heading. Wrap the content that belongs under a heading in `HeadingLevel`: headings inside render one level deeper.
35
35
 
36
36
  ```tsx
37
- import { H, HeadingLevel } from "react-headings";
37
+ import { Heading, HeadingLevel } from "react-headings";
38
38
 
39
39
  function Page() {
40
40
  return (
41
41
  <>
42
- <H>Star Wars</H> {/* h1 */}
42
+ <Heading>Star Wars</Heading> {/* h1 */}
43
43
  <HeadingLevel>
44
- <Card title="Characters"> {/* h2 */}
45
- <Card title="Luke" /> {/* h3 */}
46
- <Card title="Leia" /> {/* h3 */}
47
- <Card title="Han Solo" /> {/* h3 */}
48
- </Card>
44
+ <Heading>Characters</Heading> {/* h2 */}
45
+ <HeadingLevel>
46
+ <Section title="Luke" /> {/* h3 */}
47
+ <Section title="Leia" /> {/* h3 */}
48
+ <Section title="Han Solo" /> {/* h3 */}
49
+ </HeadingLevel>
49
50
  </HeadingLevel>
50
51
  </>
51
52
  );
52
53
  }
53
54
 
54
- function Card({ title, children }) {
55
+ function Section({ title, children }) {
55
56
  return (
56
- <article>
57
- <H>{title}</H>
57
+ <section>
58
+ <Heading>{title}</Heading>
58
59
  <HeadingLevel>{children}</HeadingLevel>
59
- </article>
60
+ </section>
60
61
  );
61
62
  }
62
63
  ```
63
64
 
64
- `Card` doesn't know its level: it renders `h2` for Characters, `h3` for each character, and `h1` on its own.
65
+ `Section` doesn't know its level: it renders `h3` here.
65
66
 
66
67
  ### Dialogs
67
68
 
@@ -70,7 +71,7 @@ Portaled elements, like dialogs, aren't part of the page outline. Use `level` to
70
71
  ```tsx
71
72
  <Dialog>
72
73
  <HeadingLevel level={1}>
73
- <H>Delete file?</H> {/* h1 */}
74
+ <Heading>Delete file?</Heading> {/* h1 */}
74
75
  </HeadingLevel>
75
76
  </Dialog>
76
77
  ```
@@ -80,14 +81,14 @@ Portaled elements, like dialogs, aren't part of the page outline. Use `level` to
80
81
  React Headings only picks the tag. Style headings however you like, or use `render` for your own component:
81
82
 
82
83
  ```tsx
83
- <H render={(props, { tag }) => <Text as={tag} size="lg" {...props} />}>
84
+ <Heading render={(props, { tag }) => <Text as={tag} size="lg" {...props} />}>
84
85
  Title
85
- </H>
86
+ </Heading>
86
87
  ```
87
88
 
88
89
  ## API
89
90
 
90
- ### `Heading` / `H`
91
+ ### `Heading`
91
92
 
92
93
  Renders `h1`–`h6` based on the current level: `h1` by default, and never deeper than `h6`.
93
94
 
@@ -97,8 +98,6 @@ Accepts every `h1` prop and a `ref`, plus:
97
98
  | -------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
98
99
  | `render` | `(props, { level, tag }) => ReactElement` | Renders your own element. Spread `props` on it (includes `children` and `ref`). |
99
100
 
100
- `H` is the same component as `Heading`. Pick one name per project.
101
-
102
101
  ### `HeadingLevel`
103
102
 
104
103
  | Prop | Type | Default | Description |
package/dist/index.d.ts CHANGED
@@ -25,7 +25,6 @@ export declare const Heading: import("react").ForwardRefExoticComponent<Omit<imp
25
25
  tag: Tag;
26
26
  }) => ReactElement;
27
27
  } & import("react").RefAttributes<HTMLHeadingElement>>;
28
- export { Heading as H };
29
28
  /**
30
29
  * Renders headings inside `offset` levels deeper (default 1), or at `level`
31
30
  * regardless of ancestors.
@@ -38,3 +37,4 @@ export declare function useHeadingLevel(): {
38
37
  level: Level;
39
38
  tag: Tag;
40
39
  };
40
+ export {};
@@ -97,7 +97,6 @@ function useInvalidPropWarning(prop, value, isValid) {
97
97
  }, [prop, value, isValid]);
98
98
  }
99
99
  export {
100
- Heading as H,
101
100
  Heading,
102
101
  HeadingLevel,
103
102
  useHeadingLevel
package/dist/index.js CHANGED
@@ -36,7 +36,6 @@ function useHeadingLevel() {
36
36
  return { level, tag: `h${level}` };
37
37
  }
38
38
  export {
39
- Heading as H,
40
39
  Heading,
41
40
  HeadingLevel,
42
41
  useHeadingLevel
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-headings",
3
- "version": "4.0.0-next.2",
3
+ "version": "4.0.0-next.3",
4
4
  "type": "module",
5
5
  "description": "Dynamic heading levels for React.",
6
6
  "author": "Alex Nault",