@ibanzajoe/uploader 0.1.0 → 0.3.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 CHANGED
@@ -64,6 +64,89 @@ Inline drop zone that can be embedded in a form.
64
64
 
65
65
  Headless hook — returns `{ open, uploading, files, errors }`.
66
66
 
67
+ ## Theming
68
+
69
+ The picker is styled entirely from `--uploader-*` CSS custom properties, so a
70
+ third-party app can restyle it to match its own brand. There are two ways to do
71
+ it — pick whichever fits your stack.
72
+
73
+ ### 1. The `theme` prop (scoped, per-instance)
74
+
75
+ Pass your design tokens as a plain object. They are applied as inline CSS
76
+ variables on that component's root, so the override is **scoped to that
77
+ instance** — two pickers on one page can carry different themes and nothing
78
+ leaks to the rest of your app. Only the keys you set change; everything else
79
+ falls back to the shipped defaults.
80
+
81
+ ```tsx
82
+ import { PickerOverlay } from '@uploader/react'
83
+ import '@uploader/react/styles.css'
84
+
85
+ <PickerOverlay
86
+ apikey="pk_…"
87
+ open={open}
88
+ onClose={() => setOpen(false)}
89
+ theme={{
90
+ accent: '#4f46e5', // your brand color
91
+ accentSoft: '#eef2ff', // tinted hover/icon background
92
+ accentRing: 'rgba(79,70,229,.28)',
93
+ radius: '12px',
94
+ font: "'Inter', sans-serif",
95
+ }}
96
+ />
97
+ ```
98
+
99
+ `DropPane` takes the same `theme` prop. See the `UploaderTheme` type for the
100
+ full token list (accent set, surfaces, text, borders, semantic colors, shadows,
101
+ radius, font, transition). A `themeToVars(theme)` helper is also exported if you
102
+ want to apply the same variables to your own wrapper element.
103
+
104
+ ### 2. CSS variables (global / page-level)
105
+
106
+ Override the variables in your own stylesheet to theme every instance at once:
107
+
108
+ ```css
109
+ :root {
110
+ --uploader-accent: #4f46e5;
111
+ --uploader-accent-soft: #eef2ff;
112
+ --uploader-radius: 12px;
113
+ }
114
+ ```
115
+
116
+ Dark mode is handled automatically when any ancestor has `data-theme="dark"`.
117
+
118
+ ## Camera capture
119
+
120
+ Both `<PickerOverlay>` and `<DropPane>` can capture a photo straight from the
121
+ device camera. A **Take photo** button appears next to **Browse files** whenever
122
+ the browser supports `getUserMedia` and the picker accepts images. The capture
123
+ flows through the exact same pipeline as a dropped or browsed file — it lands in
124
+ the queue with a preview, can be cropped/rotated in the in-picker editor, and is
125
+ then uploaded normally.
126
+
127
+ ```tsx
128
+ <PickerOverlay
129
+ apikey="pk_…"
130
+ open={open}
131
+ onClose={() => setOpen(false)}
132
+ pickerOptions={{
133
+ accept: ['image/*'],
134
+ // Sources offered to the user. Omit to offer everything supported.
135
+ fromSources: ['local_file_system', 'camera'],
136
+ // 'user' = front/selfie (mirrored, default) · 'environment' = rear camera
137
+ cameraFacingMode: 'environment',
138
+ }}
139
+ />
140
+ ```
141
+
142
+ Notes:
143
+ - The camera requires a **secure context** (HTTPS or `localhost`) and user
144
+ permission. Permission/no-camera errors are surfaced inline with a retry.
145
+ - Pass `fromSources: ['local_file_system']` to hide the camera even where it is
146
+ supported; omit `fromSources` to offer it by default.
147
+ - The `<CameraCapture>` component and the `isCameraSupported()` /
148
+ `shouldOfferCamera()` helpers are exported for fully custom pickers.
149
+
67
150
  ## Signed policies
68
151
 
69
152
  When the account has `requireSigned` enabled, pass a signed policy on upload: