adkit-react 0.1.0

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 ADDED
@@ -0,0 +1,122 @@
1
+ # adkit-react
2
+
3
+ A drop-in React component for selling direct, bookable ads on your site — no AdSense required.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install adkit-react
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```tsx
14
+ import { AdkitProvider, AdSlot } from "adkit-react"
15
+ import "adkit-react/styles.css"
16
+
17
+ function App() {
18
+ return (
19
+ <AdkitProvider siteId="your-site-id">
20
+ <AdSlot slot="sidebar" aspectRatio="1:1" price={2500} />
21
+ </AdkitProvider>
22
+ )
23
+ }
24
+ ```
25
+
26
+ ## Components
27
+
28
+ ### `<AdkitProvider>`
29
+
30
+ Wrap your app (or ad-containing subtree) with the provider to share your site ID across all slots.
31
+
32
+ ```tsx
33
+ <AdkitProvider siteId="your-site-id">
34
+ {children}
35
+ </AdkitProvider>
36
+ ```
37
+
38
+ | Prop | Type | Required | Description |
39
+ |------|------|----------|-------------|
40
+ | `siteId` | `string` | Yes | Your Adkit site ID |
41
+ | `children` | `ReactNode` | Yes | Child components |
42
+
43
+ ### `<AdSlot>`
44
+
45
+ Renders an ad placement. When no ad is booked, displays a placeholder inviting visitors to rent the space.
46
+
47
+ ```tsx
48
+ <AdSlot
49
+ slot="sidebar"
50
+ aspectRatio="16:9"
51
+ price={2500}
52
+ size="lg"
53
+ theme="auto"
54
+ />
55
+ ```
56
+
57
+ | Prop | Type | Default | Description |
58
+ |------|------|---------|-------------|
59
+ | `slot` | `string` | — | **Required.** Unique slot name (letters, numbers, hyphens, underscores) |
60
+ | `aspectRatio` | `AspectRatio` | — | **Required.** `"16:9"` \| `"4:3"` \| `"1:1"` \| `"9:16"` \| `"banner"` |
61
+ | `siteId` | `string` | — | Manual override (not needed inside `AdkitProvider`) |
62
+ | `price` | `number` | `2500` | Daily rental price in cents (2500 = $25.00) |
63
+ | `size` | `"sm"` \| `"md"` \| `"lg"` | `"lg"` | Placeholder content size |
64
+ | `theme` | `"light"` \| `"dark"` \| `"auto"` | `"auto"` | Color theme (`"auto"` follows system) |
65
+ | `className` | `string` | — | Additional CSS classes |
66
+ | `styles` | `AdSlotStyles` | — | Custom style overrides for placeholder |
67
+ | `silent` | `boolean` | `false` | Disable all event tracking |
68
+
69
+ ### `<BookingModal>`
70
+
71
+ Exported for advanced use cases. Normally opened automatically when a visitor clicks an empty slot.
72
+
73
+ ## Types
74
+
75
+ ```tsx
76
+ import type { AspectRatio, AdSlotProps, AdSlotStyles } from "adkit-react"
77
+
78
+ const ratio: AspectRatio = "16:9"
79
+
80
+ const customStyles: AdSlotStyles = {
81
+ borderColor: "#3b82f6",
82
+ backgroundColor: "transparent",
83
+ textColorPrimary: "#1a1a1a",
84
+ textColorSecondary: "#666",
85
+ buttonColor: "#3b82f6"
86
+ }
87
+ ```
88
+
89
+ ## Styling
90
+
91
+ Import the default styles:
92
+
93
+ ```tsx
94
+ import "adkit-react/styles.css"
95
+ ```
96
+
97
+ Control slot width via `className`:
98
+
99
+ ```tsx
100
+ <AdSlot slot="sidebar" aspectRatio="1:1" className="w-[300px]" />
101
+ ```
102
+
103
+ The aspect ratio is enforced by the component — only width needs to be set.
104
+
105
+ ## Hooks
106
+
107
+ ### `useAdkit()`
108
+
109
+ Access the Adkit context from any child component:
110
+
111
+ ```tsx
112
+ import { useAdkit } from "adkit-react"
113
+
114
+ function MyComponent() {
115
+ const { siteId } = useAdkit()
116
+ // ...
117
+ }
118
+ ```
119
+
120
+ ## License
121
+
122
+ Proprietary. See LICENSE for details.
@@ -0,0 +1,95 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+
4
+ type AspectRatio = "16:9" | "4:3" | "1:1" | "9:16" | "banner";
5
+ /**
6
+ * Event types sent to the Adkit API
7
+ *
8
+ * - slot_mount: Fires once per slot per page load (installation verification)
9
+ * - slot_view: Fires once when ≥50% visible (billable impression)
10
+ * - slot_click: Fires on user click
11
+ * - slot_duplicate: Diagnostics only — never billable, never blocks rendering
12
+ */
13
+ type AdkitEventType = "slot_mount" | "slot_view" | "slot_click" | "slot_duplicate";
14
+ /**
15
+ * Custom style overrides for the AdSlot placeholder.
16
+ *
17
+ * IMPORTANT: These styles affect the PLACEHOLDER only, not rendered ads.
18
+ * When a real ad is displayed, the advertiser controls the creative.
19
+ * Publishers cannot override ad content styling.
20
+ */
21
+ type AdSlotStyles = {
22
+ /** Border color of the dashed placeholder outline */
23
+ borderColor?: string;
24
+ /** Background color of the placeholder (default: transparent) */
25
+ backgroundColor?: string;
26
+ /** Primary text color for placeholder (price, CTA) */
27
+ textColorPrimary?: string;
28
+ /** Secondary text color for placeholder (label, subtext) */
29
+ textColorSecondary?: string;
30
+ /** Button background color on hover (placeholder only) */
31
+ buttonColor?: string;
32
+ };
33
+ type AdSlotProps = {
34
+ /**
35
+ * Semantic slot name (e.g. "sidebar", "header-1", "footer").
36
+ * Must be unique per placement. Only letters, numbers, hyphens, and underscores allowed.
37
+ */
38
+ slot: string;
39
+ /**
40
+ * Manual site ID override. Only needed without a Provider.
41
+ * With AdkitProvider, siteId is inherited from context.
42
+ */
43
+ siteId?: string;
44
+ /**
45
+ * Aspect ratio of the ad slot. Required.
46
+ * Determines the type/format of ad that will be displayed.
47
+ */
48
+ aspectRatio: AspectRatio;
49
+ /** Daily rental price in cents (e.g. 2500 = $25.00) */
50
+ price?: number;
51
+ /** Size variant for the placeholder content */
52
+ size?: "sm" | "md" | "lg";
53
+ /** Color theme. "auto" follows system preference. */
54
+ theme?: "light" | "dark" | "auto";
55
+ /** Additional CSS class names */
56
+ className?: string;
57
+ /** Custom style overrides for the placeholder (does not affect rendered ads) */
58
+ styles?: AdSlotStyles;
59
+ /** Disable all event tracking */
60
+ silent?: boolean;
61
+ };
62
+
63
+ declare function AdSlot({ slot, siteId: manualSiteId, aspectRatio, price, size, theme, className, styles, silent }: AdSlotProps): react_jsx_runtime.JSX.Element;
64
+
65
+ type AdkitProviderProps = {
66
+ /** Your Adkit site ID */
67
+ siteId: string;
68
+ children: React.ReactNode;
69
+ };
70
+ declare function AdkitProvider({ siteId, children }: AdkitProviderProps): react_jsx_runtime.JSX.Element;
71
+
72
+ /**
73
+ * BookingModal — intentionally simple.
74
+ *
75
+ * This modal is informational only. It exists to build trust with the visitor
76
+ * before redirecting them to adkit.io where the actual booking flow lives.
77
+ * No forms, no checkout, no data fetching — just copy and a redirect.
78
+ */
79
+ type BookingModalProps = {
80
+ siteId: string;
81
+ slot: string;
82
+ /** Daily price in cents (e.g. 2500 = $25) */
83
+ price: number;
84
+ onClose: () => void;
85
+ };
86
+ declare function BookingModal({ siteId, slot, price, onClose }: BookingModalProps): react_jsx_runtime.JSX.Element;
87
+
88
+ type AdkitContextValue = {
89
+ siteId: string;
90
+ registerSlot: (identity: string) => boolean;
91
+ unregisterSlot: (identity: string) => void;
92
+ };
93
+ declare function useAdkit(): AdkitContextValue;
94
+
95
+ export { AdSlot, type AdSlotProps, type AdSlotStyles, type AdkitEventType, AdkitProvider, type AdkitProviderProps, type AspectRatio, BookingModal, useAdkit };
@@ -0,0 +1,95 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+
4
+ type AspectRatio = "16:9" | "4:3" | "1:1" | "9:16" | "banner";
5
+ /**
6
+ * Event types sent to the Adkit API
7
+ *
8
+ * - slot_mount: Fires once per slot per page load (installation verification)
9
+ * - slot_view: Fires once when ≥50% visible (billable impression)
10
+ * - slot_click: Fires on user click
11
+ * - slot_duplicate: Diagnostics only — never billable, never blocks rendering
12
+ */
13
+ type AdkitEventType = "slot_mount" | "slot_view" | "slot_click" | "slot_duplicate";
14
+ /**
15
+ * Custom style overrides for the AdSlot placeholder.
16
+ *
17
+ * IMPORTANT: These styles affect the PLACEHOLDER only, not rendered ads.
18
+ * When a real ad is displayed, the advertiser controls the creative.
19
+ * Publishers cannot override ad content styling.
20
+ */
21
+ type AdSlotStyles = {
22
+ /** Border color of the dashed placeholder outline */
23
+ borderColor?: string;
24
+ /** Background color of the placeholder (default: transparent) */
25
+ backgroundColor?: string;
26
+ /** Primary text color for placeholder (price, CTA) */
27
+ textColorPrimary?: string;
28
+ /** Secondary text color for placeholder (label, subtext) */
29
+ textColorSecondary?: string;
30
+ /** Button background color on hover (placeholder only) */
31
+ buttonColor?: string;
32
+ };
33
+ type AdSlotProps = {
34
+ /**
35
+ * Semantic slot name (e.g. "sidebar", "header-1", "footer").
36
+ * Must be unique per placement. Only letters, numbers, hyphens, and underscores allowed.
37
+ */
38
+ slot: string;
39
+ /**
40
+ * Manual site ID override. Only needed without a Provider.
41
+ * With AdkitProvider, siteId is inherited from context.
42
+ */
43
+ siteId?: string;
44
+ /**
45
+ * Aspect ratio of the ad slot. Required.
46
+ * Determines the type/format of ad that will be displayed.
47
+ */
48
+ aspectRatio: AspectRatio;
49
+ /** Daily rental price in cents (e.g. 2500 = $25.00) */
50
+ price?: number;
51
+ /** Size variant for the placeholder content */
52
+ size?: "sm" | "md" | "lg";
53
+ /** Color theme. "auto" follows system preference. */
54
+ theme?: "light" | "dark" | "auto";
55
+ /** Additional CSS class names */
56
+ className?: string;
57
+ /** Custom style overrides for the placeholder (does not affect rendered ads) */
58
+ styles?: AdSlotStyles;
59
+ /** Disable all event tracking */
60
+ silent?: boolean;
61
+ };
62
+
63
+ declare function AdSlot({ slot, siteId: manualSiteId, aspectRatio, price, size, theme, className, styles, silent }: AdSlotProps): react_jsx_runtime.JSX.Element;
64
+
65
+ type AdkitProviderProps = {
66
+ /** Your Adkit site ID */
67
+ siteId: string;
68
+ children: React.ReactNode;
69
+ };
70
+ declare function AdkitProvider({ siteId, children }: AdkitProviderProps): react_jsx_runtime.JSX.Element;
71
+
72
+ /**
73
+ * BookingModal — intentionally simple.
74
+ *
75
+ * This modal is informational only. It exists to build trust with the visitor
76
+ * before redirecting them to adkit.io where the actual booking flow lives.
77
+ * No forms, no checkout, no data fetching — just copy and a redirect.
78
+ */
79
+ type BookingModalProps = {
80
+ siteId: string;
81
+ slot: string;
82
+ /** Daily price in cents (e.g. 2500 = $25) */
83
+ price: number;
84
+ onClose: () => void;
85
+ };
86
+ declare function BookingModal({ siteId, slot, price, onClose }: BookingModalProps): react_jsx_runtime.JSX.Element;
87
+
88
+ type AdkitContextValue = {
89
+ siteId: string;
90
+ registerSlot: (identity: string) => boolean;
91
+ unregisterSlot: (identity: string) => void;
92
+ };
93
+ declare function useAdkit(): AdkitContextValue;
94
+
95
+ export { AdSlot, type AdSlotProps, type AdSlotStyles, type AdkitEventType, AdkitProvider, type AdkitProviderProps, type AspectRatio, BookingModal, useAdkit };