@mijn-ui/react-sonner 0.1.0 → 0.1.1

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
@@ -46,9 +46,28 @@ anything from it would pull sonner's bytes in whether or not it shows a toast.
46
46
 
47
47
  The toaster maps sonner's surface variables (`--normal-bg`, `--success-bg`, …)
48
48
  onto mijn-ui theme tokens, so toasts follow light/dark and any re-themed palette
49
- without per-app restyling. Pass `unstyled` to drop that mapping entirely and
49
+ without per-app restyling. With `richColors`, success, warning and error use
50
+ their status tiers and info uses the categorical blue tier — not the brand, so
51
+ info stays distinct from success whatever the brand colour is. Pass `unstyled` to drop that mapping entirely and
50
52
  supply your own `classNames`.
51
53
 
54
+ ### Overriding a slot
55
+
56
+ Sonner injects its own stylesheet at runtime, outside any CSS cascade layer.
57
+ Unlayered rules beat every Tailwind utility (those live in `@layer utilities`)
58
+ regardless of specificity, so the toaster's slot classes are `!important`
59
+ wherever sonner sets the same property. Do the same in your own `classNames`
60
+ when you override one of those properties:
61
+
62
+ ```tsx
63
+ <Toaster classNames={{ title: "font-bold!", actionButton: "rounded-full!" }} />
64
+ ```
65
+
66
+ Properties sonner leaves alone (`uppercase`, `py-2`, …) need no `!`. The
67
+ toast's own background, text and border colours are the exception: they come
68
+ from the variables above, so set those variables (or use `richColors`) rather
69
+ than classes.
70
+
52
71
  ## License
53
72
 
54
73
  This project is licensed under the terms of the [MIT license.](https://github.com/mijn-ui/mijn-ui-react/blob/main/LICENSE)
package/dist/index.d.ts CHANGED
@@ -6,6 +6,18 @@ import { UnstyledComponentWithSlots } from '@mijn-ui/react-core';
6
6
  import { ToasterProps } from 'sonner';
7
7
  export { ToasterProps, toast, useSonner } from 'sonner';
8
8
 
9
+ /**
10
+ * Why so many `!`: sonner injects its own stylesheet at runtime, outside any
11
+ * cascade layer, and unlayered rules beat everything in Tailwind's
12
+ * `@layer utilities` whatever their specificity. So a class here only applies
13
+ * if sonner does not set the same property — or if it is `!important`. Every
14
+ * class below that competes with a sonner property carries `!`; the rest
15
+ * (`py-1`, `group`) do not need it. `sonner.test.tsx` checks this against
16
+ * sonner's actual stylesheet.
17
+ *
18
+ * The same goes for your own `classNames`: to override a property sonner
19
+ * sets, add `!` (`title: "font-bold!"`).
20
+ */
9
21
  declare const sonnerStyles: tailwind_variants.TVReturnType<{
10
22
  [key: string]: {
11
23
  [key: string]: tailwind_merge.ClassNameValue | {
package/dist/index.js CHANGED
@@ -11,13 +11,19 @@ import { toast, useSonner } from "sonner";
11
11
  import { jsx } from "react/jsx-runtime";
12
12
  var sonnerStyles = tv({
13
13
  slots: {
14
- toast: "group border-outline-secondary bg-bg-default-alt text-fg-default rounded-lg border shadow-lg",
15
- title: "text-fg-default text-sm font-semibold",
16
- description: "text-fg-secondary! text-sm",
17
- actionButton: "bg-bg-brand text-on-bg-brand rounded-md px-2.5 py-1 text-xs font-medium",
18
- cancelButton: "bg-bg-secondary text-fg-secondary rounded-md px-2.5 py-1 text-xs font-medium",
19
- closeButton: "border-outline-secondary bg-bg-default-alt text-fg-tertiary hover:text-fg-default",
20
- icon: "shrink-0"
14
+ // The toast's colours are the exception: they reach sonner through its
15
+ // --normal-* variables (TOASTER_THEME below), not through `!`, so that
16
+ // `richColors` can still recolour a success or error toast. These three
17
+ // classes are the fallback for a toast sonner leaves unstyled.
18
+ toast: "group border-outline-secondary bg-bg-default-alt text-fg-default rounded-(--mijn-radius-lg)! border! shadow-(--mijn-shadow-lg)! focus-visible:ring-outline-brand focus-visible:mijn-focus-ring!",
19
+ // No colour: sonner makes the title inherit the toast's, which is what
20
+ // lets `richColors` tint it.
21
+ title: "text-sm! font-semibold!",
22
+ description: "text-fg-secondary! text-sm!",
23
+ actionButton: "bg-bg-brand! text-on-bg-brand! rounded-md! px-2.5! py-1 text-xs! font-medium!",
24
+ cancelButton: "bg-bg-secondary! text-fg-secondary! rounded-md! px-2.5! py-1 text-xs! font-medium!",
25
+ closeButton: "border-outline-secondary! bg-bg-default-alt! text-fg-tertiary! hover:bg-bg-secondary! hover:text-fg-default!",
26
+ icon: "shrink-0!"
21
27
  }
22
28
  });
23
29
  var TOASTER_THEME = {
@@ -33,9 +39,12 @@ var TOASTER_THEME = {
33
39
  "--warning-bg": "var(--color-bg-warning-subtle)",
34
40
  "--warning-text": "var(--color-on-bg-warning-subtle)",
35
41
  "--warning-border": "var(--color-outline-warning-subtle)",
36
- "--info-bg": "var(--color-bg-brand-subtle)",
37
- "--info-text": "var(--color-on-bg-brand-subtle)",
38
- "--info-border": "var(--color-outline-brand-subtle)"
42
+ // Info gets the categorical blue tier, not brand: with a green brand (as in
43
+ // PicoAI) brand-subtle is success-subtle, and info toasts looked like
44
+ // success ones.
45
+ "--info-bg": "var(--color-bg-blue-subtle)",
46
+ "--info-text": "var(--color-on-bg-blue-subtle)",
47
+ "--info-border": "var(--color-outline-blue-subtle)"
39
48
  };
40
49
  var Toaster = ({
41
50
  unstyled,
@@ -1 +1 @@
1
- {"inputs":{"src/sonner.tsx":{"bytes":4181,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@mijn-ui/react-core","kind":"import-statement","external":true},{"path":"sonner","kind":"import-statement","external":true},{"path":"tailwind-variants","kind":"import-statement","external":true},{"path":"sonner","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":25,"imports":[{"path":"src/sonner.tsx","kind":"import-statement","original":"./sonner"}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"path":"@mijn-ui/react-core","kind":"import-statement","external":true},{"path":"sonner","kind":"import-statement","external":true},{"path":"tailwind-variants","kind":"import-statement","external":true},{"path":"sonner","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"exports":["Toaster","sonnerStyles","toast","useSonner"],"entryPoint":"src/index.ts","inputs":{"src/sonner.tsx":{"bytesInOutput":2766},"src/index.ts":{"bytesInOutput":0}},"bytes":2859}}}
1
+ {"inputs":{"src/sonner.tsx":{"bytes":5494,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@mijn-ui/react-core","kind":"import-statement","external":true},{"path":"sonner","kind":"import-statement","external":true},{"path":"tailwind-variants","kind":"import-statement","external":true},{"path":"sonner","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":25,"imports":[{"path":"src/sonner.tsx","kind":"import-statement","original":"./sonner"}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"path":"@mijn-ui/react-core","kind":"import-statement","external":true},{"path":"sonner","kind":"import-statement","external":true},{"path":"tailwind-variants","kind":"import-statement","external":true},{"path":"sonner","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"exports":["Toaster","sonnerStyles","toast","useSonner"],"entryPoint":"src/index.ts","inputs":{"src/sonner.tsx":{"bytesInOutput":3467},"src/index.ts":{"bytesInOutput":0}},"bytes":3560}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mijn-ui/react-sonner",
3
3
  "author": "Htet Aung Lin<htetaunglin.coder@gmail.com>",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "homepage": "https://mijn-ui.vercel.app",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -28,14 +28,15 @@
28
28
  "react": "19.0.1",
29
29
  "react-dom": "19.0.1",
30
30
  "sonner": "^2.0.7",
31
- "@mijn-ui/react-button": "0.6.0",
32
- "@mijn-ui/react-core": "0.5.1",
31
+ "@mijn-ui/react-button": "0.7.0",
32
+ "@mijn-ui/react-core": "0.6.0",
33
33
  "eslint-config-custom": "0.0.1",
34
34
  "tsconfig": "0.0.0",
35
- "tsup-config": "0.0.0"
35
+ "tsup-config": "0.0.0",
36
+ "test-utils": "0.0.0"
36
37
  },
37
38
  "peerDependencies": {
38
- "@mijn-ui/react-core": "^0.5.0",
39
+ "@mijn-ui/react-core": "^0.6.0",
39
40
  "react": "^19.0",
40
41
  "react-dom": "^19.0",
41
42
  "sonner": "^2.0.0",