@northslopetech/altitude-ui 1.2.0 → 1.6.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
@@ -1,13 +1,13 @@
1
- # @nslp/altitude
1
+ # @northslopetech/altitude-ui
2
2
 
3
3
  React UI components for the Altitude design system, built on top of [shadcn/ui](https://ui.shadcn.com/) and styled with Altitude design tokens.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @nslp/altitude
8
+ npm install @northslopetech/altitude-ui
9
9
  # or
10
- pnpm add @nslp/altitude
10
+ pnpm add @northslopetech/altitude-ui
11
11
  ```
12
12
 
13
13
  ## Architecture
@@ -18,10 +18,21 @@ This package combines the best of both worlds:
18
18
  - **Altitude Design Tokens**: Replaces shadcn/ui's default colors and typography with our design system
19
19
 
20
20
  Components are built using:
21
+
21
22
  - **Radix UI**: For accessibility and behavior
22
23
  - **class-variance-authority**: For type-safe variant management
23
24
  - **Tailwind CSS**: For styling with Altitude design tokens
24
25
 
26
+ ## Available Components
27
+
28
+ This package includes the following components:
29
+
30
+ - **Button** - Interactive button component with multiple variants and sizes
31
+ - **Select** - Dropdown selection component with search capabilities
32
+ - **DatePicker** - Date selection component with calendar popup
33
+ - **FormField** - Form field wrapper with label and error handling
34
+ - **Typography** - Text components with design system typography tokens
35
+
25
36
  ## Usage
26
37
 
27
38
  ### Button
@@ -29,21 +40,21 @@ Components are built using:
29
40
  The Button component is built on shadcn/ui's Button but styled with Altitude design tokens.
30
41
 
31
42
  ```tsx
32
- import { Button } from '@nslp/altitude';
43
+ import { Button } from "@northslopetech/altitude-ui";
33
44
 
34
45
  function Example() {
35
46
  return (
36
47
  <div className="flex gap-2 flex-wrap">
37
48
  {/* Default variant */}
38
49
  <Button>Primary Button</Button>
39
-
50
+
40
51
  {/* Other variants */}
41
52
  <Button variant="secondary">Secondary</Button>
42
53
  <Button variant="outline">Outline</Button>
43
54
  <Button variant="ghost">Ghost</Button>
44
55
  <Button variant="link">Link</Button>
45
56
  <Button variant="destructive">Destructive</Button>
46
-
57
+
47
58
  {/* Different sizes */}
48
59
  <Button size="sm">Small</Button>
49
60
  <Button size="lg">Large</Button>
@@ -56,11 +67,11 @@ function Example() {
56
67
 
57
68
  #### Button Props
58
69
 
59
- | Prop | Type | Default | Description |
60
- |------|------|---------|-------------|
61
- | `variant` | `'default' \| 'secondary' \| 'outline' \| 'ghost' \| 'link' \| 'destructive'` | `'default'` | Visual style variant |
62
- | `size` | `'sm' \| 'default' \| 'lg' \| 'xl' \| 'icon'` | `'default'` | Size of the button |
63
- | `asChild` | `boolean` | `false` | Render as child element (for composition) |
70
+ | Prop | Type | Default | Description |
71
+ | --------- | ----------------------------------------------------------------------------- | ----------- | ----------------------------------------- |
72
+ | `variant` | `'default' \| 'secondary' \| 'outline' \| 'ghost' \| 'link' \| 'destructive'` | `'default'` | Visual style variant |
73
+ | `size` | `'sm' \| 'default' \| 'lg' \| 'xl' \| 'icon'` | `'default'` | Size of the button |
74
+ | `asChild` | `boolean` | `false` | Render as child element (for composition) |
64
75
 
65
76
  All standard HTML button attributes are also supported.
66
77
 
@@ -73,17 +84,38 @@ The Button component uses Altitude design tokens:
73
84
  - **Focus states**: `primary-500` ring color
74
85
  - **Hover states**: Consistent with design system color scales
75
86
 
87
+ ### Checkbox
88
+
89
+ The Checkbox component is built on Radix UI Checkbox with Altitude design tokens.
90
+
91
+ ```tsx
92
+ import { Checkbox } from "@nslp/altitude";
93
+
94
+ function Example() {
95
+ return (
96
+ <div className="flex items-center space-x-2">
97
+ <Checkbox id="terms" />
98
+ <label htmlFor="terms">Accept terms and conditions</label>
99
+ </div>
100
+ );
101
+ }
102
+ ```
103
+
104
+ #### Checkbox Props
105
+
106
+ All standard Radix UI Checkbox attributes are also supported.
107
+
76
108
  ### asChild Pattern
77
109
 
78
110
  Use the `asChild` prop for composition with other components (powered by Radix UI Slot):
79
111
 
80
112
  ```tsx
81
- import { Button } from '@nslp/altitude';
82
- import Link from 'next/link';
113
+ import { Button } from "@northslopetech/altitude-ui";
114
+ import Link from "next/link";
83
115
 
84
116
  <Button asChild>
85
117
  <Link href="/dashboard">Go to Dashboard</Link>
86
- </Button>
118
+ </Button>;
87
119
  ```
88
120
 
89
121
  ## shadcn/ui Integration
@@ -97,11 +129,22 @@ This package is configured to work with shadcn/ui:
97
129
 
98
130
  ## Development
99
131
 
132
+ ### Prerequisites
133
+
134
+ This package depends on design tokens. Before development, ensure tokens are built:
135
+
136
+ ```bash
137
+ # From the root directory
138
+ pnpm tokens:build
139
+ ```
140
+
141
+ ### Commands
142
+
100
143
  ```bash
101
144
  # Build the package
102
145
  pnpm build
103
146
 
104
- # Watch for changes
147
+ # Watch for changes (tokens must be built first)
105
148
  pnpm dev
106
149
 
107
150
  # Run linting
@@ -114,6 +157,8 @@ pnpm check-types
114
157
  npx shadcn@latest add [component-name]
115
158
  ```
116
159
 
160
+ > **Note**: The package includes a prebuild script that automatically builds tokens, but for development mode you should build tokens manually first.
161
+
117
162
  ## Adding New Components
118
163
 
119
164
  To add more shadcn/ui components:
@@ -121,4 +166,79 @@ To add more shadcn/ui components:
121
166
  1. Run `npx shadcn@latest add [component-name]`
122
167
  2. Update the generated component to use Altitude design tokens
123
168
  3. Export the component from `src/index.ts`
124
- 4. Update this README with usage examples
169
+ 4. Update this README with usage examples
170
+
171
+ ### Select
172
+
173
+ A dropdown selection component with built-in search and filtering:
174
+
175
+ ```tsx
176
+ import { Select } from "@northslopetech/altitude-ui";
177
+
178
+ const options = [
179
+ { value: "apple", label: "Apple" },
180
+ { value: "banana", label: "Banana" },
181
+ { value: "orange", label: "Orange" },
182
+ ];
183
+
184
+ function Example() {
185
+ return (
186
+ <Select
187
+ placeholder="Select a fruit..."
188
+ options={options}
189
+ onValueChange={(value) => console.log(value)}
190
+ />
191
+ );
192
+ }
193
+ ```
194
+
195
+ ### DatePicker
196
+
197
+ A date selection component with calendar popup:
198
+
199
+ ```tsx
200
+ import { DatePicker } from "@northslopetech/altitude-ui";
201
+
202
+ function Example() {
203
+ const [date, setDate] = useState<Date>();
204
+
205
+ return (
206
+ <DatePicker selected={date} onSelect={setDate} placeholder="Pick a date" />
207
+ );
208
+ }
209
+ ```
210
+
211
+ ### FormField
212
+
213
+ A form field wrapper that provides consistent styling and error handling:
214
+
215
+ ```tsx
216
+ import { FormField, Input } from "@northslopetech/altitude-ui";
217
+
218
+ function Example() {
219
+ return (
220
+ <FormField label="Email Address" error="Please enter a valid email">
221
+ <Input type="email" placeholder="Enter your email" />
222
+ </FormField>
223
+ );
224
+ }
225
+ ```
226
+
227
+ ### Typography
228
+
229
+ Pre-styled text components using design system typography tokens:
230
+
231
+ ```tsx
232
+ import { Typography } from "@northslopetech/altitude-ui";
233
+
234
+ function Example() {
235
+ return (
236
+ <div>
237
+ <Typography variant="display-xl">Large Display Text</Typography>
238
+ <Typography variant="heading-lg">Section Heading</Typography>
239
+ <Typography variant="body-md">Body paragraph text</Typography>
240
+ <Typography variant="label-sm-bold">Form Label</Typography>
241
+ </div>
242
+ );
243
+ }
244
+ ```
package/dist/index.d.mts CHANGED
@@ -1,11 +1,19 @@
1
1
  import * as class_variance_authority_types from 'class-variance-authority/types';
2
2
  import * as React from 'react';
3
+ import { JSX } from 'react';
3
4
  import { VariantProps } from 'class-variance-authority';
4
5
  import * as SelectPrimitive from '@radix-ui/react-select';
6
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
5
7
 
8
+ declare enum ButtonSize {
9
+ Small = "sm",
10
+ Default = "default",
11
+ Large = "lg",
12
+ Icon = "icon"
13
+ }
6
14
  declare const buttonVariants: (props?: ({
7
15
  variant?: "default" | "outline" | "destructive" | "destructive-subtle" | "ghost" | "link" | null | undefined;
8
- size?: "default" | "sm" | "lg" | "icon" | null | undefined;
16
+ size?: ButtonSize | null | undefined;
9
17
  } & class_variance_authority_types.ClassProp) | undefined) => string;
10
18
  interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
11
19
  asChild?: boolean;
@@ -34,7 +42,7 @@ interface SelectTriggerProps extends React.ComponentPropsWithoutRef<typeof Selec
34
42
  declare const SelectTrigger: React.ForwardRefExoticComponent<SelectTriggerProps & React.RefAttributes<HTMLButtonElement>>;
35
43
  declare const SelectScrollUpButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollUpButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
36
44
  declare const SelectScrollDownButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollDownButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
37
- interface SelectContentProps extends Omit<React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>, 'position'>, VariantProps<typeof selectContentVariants> {
45
+ interface SelectContentProps extends Omit<React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>, "position">, VariantProps<typeof selectContentVariants> {
38
46
  }
39
47
  declare const SelectContent: React.ForwardRefExoticComponent<SelectContentProps & React.RefAttributes<HTMLDivElement>>;
40
48
  declare const SelectLabel: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -53,4 +61,74 @@ interface FormFieldProps {
53
61
  }
54
62
  declare const FormField: React.ForwardRefExoticComponent<FormFieldProps & React.RefAttributes<HTMLDivElement>>;
55
63
 
56
- export { Button, type ButtonProps, FormField, type FormFieldProps, Select, SelectContent, type SelectContentProps, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, type SelectTriggerProps, SelectValue, Typography, type TypographyProps, buttonVariants, selectTriggerVariants, typographyVariants };
64
+ declare const datePickerTriggerVariants: (props?: class_variance_authority_types.ClassProp | undefined) => string;
65
+ interface DatePickerProps {
66
+ value?: Date;
67
+ onValueChange?: (date: Date | undefined) => void;
68
+ defaultValue?: Date | string | number;
69
+ disabled?: boolean;
70
+ placeholder?: string;
71
+ className?: string;
72
+ }
73
+ declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<HTMLButtonElement>>;
74
+
75
+ declare const checkboxVariants: (props?: class_variance_authority_types.ClassProp | undefined) => string;
76
+ interface CheckboxProps extends React.ComponentProps<typeof CheckboxPrimitive.Root> {
77
+ className?: string;
78
+ }
79
+ declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
80
+
81
+ declare enum UploadState {
82
+ Default = "default",
83
+ DragOver = "dragOver",
84
+ Error = "error",
85
+ Uploading = "uploading",
86
+ Success = "success"
87
+ }
88
+ declare const uploadVariants: (props?: ({
89
+ state?: "default" | "error" | "dragOver" | "uploading" | "success" | null | undefined;
90
+ disabled?: boolean | null | undefined;
91
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
92
+ interface UploadProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onError"> {
93
+ endpoint?: string;
94
+ onFileSelect?: (files: File[]) => void;
95
+ onUploadProgress?: (progress: number) => void;
96
+ onUploadError?: (error: string) => void;
97
+ onUploadComplete?: (files: File[]) => void;
98
+ onUploadSuccess?: (response: unknown) => void;
99
+ maxFileSize?: number;
100
+ acceptedFileTypes?: string[];
101
+ disabled?: boolean;
102
+ state?: UploadState;
103
+ progress?: number;
104
+ errorMessage?: string;
105
+ loading?: boolean;
106
+ }
107
+ declare const Upload: React.ForwardRefExoticComponent<UploadProps & React.RefAttributes<HTMLDivElement>>;
108
+
109
+ declare const inputVariants: (props?: ({
110
+ variant?: "textarea" | "input" | null | undefined;
111
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
112
+ interface BaseInputProps extends VariantProps<typeof inputVariants> {
113
+ className?: string;
114
+ style?: React.CSSProperties;
115
+ onClear?: () => void;
116
+ }
117
+ interface InputFieldProps extends BaseInputProps, Omit<React.InputHTMLAttributes<HTMLInputElement>, "style"> {
118
+ variant?: "input";
119
+ }
120
+ interface TextareaFieldProps extends BaseInputProps, Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, "style"> {
121
+ variant: "textarea";
122
+ }
123
+ type InputProps = InputFieldProps | TextareaFieldProps;
124
+ interface InputComponent {
125
+ (props: InputFieldProps & {
126
+ ref?: React.Ref<HTMLInputElement>;
127
+ }): JSX.Element;
128
+ (props: TextareaFieldProps & {
129
+ ref?: React.Ref<HTMLTextAreaElement>;
130
+ }): JSX.Element;
131
+ }
132
+ declare const TypedInput: InputComponent;
133
+
134
+ export { Button, type ButtonProps, ButtonSize, Checkbox, type CheckboxProps, DatePicker, type DatePickerProps, FormField, type FormFieldProps, TypedInput as Input, type InputFieldProps, type InputProps, Select, SelectContent, type SelectContentProps, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, type SelectTriggerProps, SelectValue, type TextareaFieldProps, Typography, type TypographyProps, Upload, type UploadProps, UploadState, buttonVariants, checkboxVariants, datePickerTriggerVariants, inputVariants, selectTriggerVariants, typographyVariants, uploadVariants };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,19 @@
1
1
  import * as class_variance_authority_types from 'class-variance-authority/types';
2
2
  import * as React from 'react';
3
+ import { JSX } from 'react';
3
4
  import { VariantProps } from 'class-variance-authority';
4
5
  import * as SelectPrimitive from '@radix-ui/react-select';
6
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
5
7
 
8
+ declare enum ButtonSize {
9
+ Small = "sm",
10
+ Default = "default",
11
+ Large = "lg",
12
+ Icon = "icon"
13
+ }
6
14
  declare const buttonVariants: (props?: ({
7
15
  variant?: "default" | "outline" | "destructive" | "destructive-subtle" | "ghost" | "link" | null | undefined;
8
- size?: "default" | "sm" | "lg" | "icon" | null | undefined;
16
+ size?: ButtonSize | null | undefined;
9
17
  } & class_variance_authority_types.ClassProp) | undefined) => string;
10
18
  interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
11
19
  asChild?: boolean;
@@ -34,7 +42,7 @@ interface SelectTriggerProps extends React.ComponentPropsWithoutRef<typeof Selec
34
42
  declare const SelectTrigger: React.ForwardRefExoticComponent<SelectTriggerProps & React.RefAttributes<HTMLButtonElement>>;
35
43
  declare const SelectScrollUpButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollUpButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
36
44
  declare const SelectScrollDownButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollDownButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
37
- interface SelectContentProps extends Omit<React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>, 'position'>, VariantProps<typeof selectContentVariants> {
45
+ interface SelectContentProps extends Omit<React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>, "position">, VariantProps<typeof selectContentVariants> {
38
46
  }
39
47
  declare const SelectContent: React.ForwardRefExoticComponent<SelectContentProps & React.RefAttributes<HTMLDivElement>>;
40
48
  declare const SelectLabel: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -53,4 +61,74 @@ interface FormFieldProps {
53
61
  }
54
62
  declare const FormField: React.ForwardRefExoticComponent<FormFieldProps & React.RefAttributes<HTMLDivElement>>;
55
63
 
56
- export { Button, type ButtonProps, FormField, type FormFieldProps, Select, SelectContent, type SelectContentProps, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, type SelectTriggerProps, SelectValue, Typography, type TypographyProps, buttonVariants, selectTriggerVariants, typographyVariants };
64
+ declare const datePickerTriggerVariants: (props?: class_variance_authority_types.ClassProp | undefined) => string;
65
+ interface DatePickerProps {
66
+ value?: Date;
67
+ onValueChange?: (date: Date | undefined) => void;
68
+ defaultValue?: Date | string | number;
69
+ disabled?: boolean;
70
+ placeholder?: string;
71
+ className?: string;
72
+ }
73
+ declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<HTMLButtonElement>>;
74
+
75
+ declare const checkboxVariants: (props?: class_variance_authority_types.ClassProp | undefined) => string;
76
+ interface CheckboxProps extends React.ComponentProps<typeof CheckboxPrimitive.Root> {
77
+ className?: string;
78
+ }
79
+ declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
80
+
81
+ declare enum UploadState {
82
+ Default = "default",
83
+ DragOver = "dragOver",
84
+ Error = "error",
85
+ Uploading = "uploading",
86
+ Success = "success"
87
+ }
88
+ declare const uploadVariants: (props?: ({
89
+ state?: "default" | "error" | "dragOver" | "uploading" | "success" | null | undefined;
90
+ disabled?: boolean | null | undefined;
91
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
92
+ interface UploadProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onError"> {
93
+ endpoint?: string;
94
+ onFileSelect?: (files: File[]) => void;
95
+ onUploadProgress?: (progress: number) => void;
96
+ onUploadError?: (error: string) => void;
97
+ onUploadComplete?: (files: File[]) => void;
98
+ onUploadSuccess?: (response: unknown) => void;
99
+ maxFileSize?: number;
100
+ acceptedFileTypes?: string[];
101
+ disabled?: boolean;
102
+ state?: UploadState;
103
+ progress?: number;
104
+ errorMessage?: string;
105
+ loading?: boolean;
106
+ }
107
+ declare const Upload: React.ForwardRefExoticComponent<UploadProps & React.RefAttributes<HTMLDivElement>>;
108
+
109
+ declare const inputVariants: (props?: ({
110
+ variant?: "textarea" | "input" | null | undefined;
111
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
112
+ interface BaseInputProps extends VariantProps<typeof inputVariants> {
113
+ className?: string;
114
+ style?: React.CSSProperties;
115
+ onClear?: () => void;
116
+ }
117
+ interface InputFieldProps extends BaseInputProps, Omit<React.InputHTMLAttributes<HTMLInputElement>, "style"> {
118
+ variant?: "input";
119
+ }
120
+ interface TextareaFieldProps extends BaseInputProps, Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, "style"> {
121
+ variant: "textarea";
122
+ }
123
+ type InputProps = InputFieldProps | TextareaFieldProps;
124
+ interface InputComponent {
125
+ (props: InputFieldProps & {
126
+ ref?: React.Ref<HTMLInputElement>;
127
+ }): JSX.Element;
128
+ (props: TextareaFieldProps & {
129
+ ref?: React.Ref<HTMLTextAreaElement>;
130
+ }): JSX.Element;
131
+ }
132
+ declare const TypedInput: InputComponent;
133
+
134
+ export { Button, type ButtonProps, ButtonSize, Checkbox, type CheckboxProps, DatePicker, type DatePickerProps, FormField, type FormFieldProps, TypedInput as Input, type InputFieldProps, type InputProps, Select, SelectContent, type SelectContentProps, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, type SelectTriggerProps, SelectValue, type TextareaFieldProps, Typography, type TypographyProps, Upload, type UploadProps, UploadState, buttonVariants, checkboxVariants, datePickerTriggerVariants, inputVariants, selectTriggerVariants, typographyVariants, uploadVariants };