nitro-web 0.0.31 → 0.0.32

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/client/index.ts CHANGED
@@ -42,10 +42,10 @@ export { Checkbox } from '../components/partials/form/checkbox'
42
42
  export { Drop } from '../components/partials/form/drop'
43
43
  export { DropHandler } from '../components/partials/form/drop-handler'
44
44
  export { FormError } from '../components/partials/form/form-error'
45
- export { Field } from '../components/partials/form/input'
46
- export { FieldColor, type FieldColorProps } from '../components/partials/form/input-color'
47
- export { FieldCurrency, type FieldCurrencyProps } from '../components/partials/form/input-currency'
48
- export { FieldDate, type FieldDateProps } from '../components/partials/form/input-date'
45
+ export { Field } from '../components/partials/form/field'
46
+ export { FieldColor, type FieldColorProps } from '../components/partials/form/field-color'
47
+ export { FieldCurrency, type FieldCurrencyProps } from '../components/partials/form/field-currency'
48
+ export { FieldDate, type FieldDateProps } from '../components/partials/form/field-date'
49
49
  export { Location } from '../components/partials/form/location'
50
50
  export { Select, getSelectStyle } from '../components/partials/form/select'
51
51
  export { Toggle } from '../components/partials/form/toggle'
@@ -27,6 +27,6 @@ export function Dashboard() {
27
27
 
28
28
  const style = css`
29
29
  .example-usage-of-tailwind-variable {
30
- color: ${theme('colors.dark')};
30
+ color: ${theme('colors.primary')};
31
31
  }
32
32
  `
@@ -80,7 +80,7 @@ export function Accordion({ children, className, expanded, onChange }: Accordion
80
80
  return (
81
81
  <div
82
82
  ref={el}
83
- class={['accordion', className, state ? 'is-expanded' : ''].filter(o => o).join(' ')}
83
+ class={['accordion', className, state ? 'is-expanded' : ''].filter(o => o).join(' nitro-accordion')}
84
84
  onClick={onClick}
85
85
  css={style}
86
86
  >
@@ -13,7 +13,7 @@ type AvatarProps = {
13
13
  }
14
14
 
15
15
  export function Avatar({ awsUrl, isRound, user, showPlaceholderImage, className }: AvatarProps) {
16
- const classes = 'rounded-full w-[30px] h-[30px] object-cover transition-all duration-150 ease ' + (className || '')
16
+ const classes = 'rounded-full w-[30px] h-[30px] object-cover transition-all duration-150 ease nitro-avatar ' + (className || '')
17
17
 
18
18
  function getInitials(user: User) {
19
19
  const text = (user.firstName ? [user.firstName, user.lastName] : (user?.name||'').split(' ')).map((o) => o?.charAt(0))
@@ -41,10 +41,10 @@ export function Button({
41
41
 
42
42
  // Button sizes
43
43
  const sizes = {
44
- xs: 'px-2 py-1 text-xs rounded',
45
- sm: 'px-2.5 py-1.5 text-sm rounded-md',
46
- md: 'px-3 py-2 text-sm rounded-md',
47
- lg: 'px-3.5 py-2.5 text-sm rounded-md',
44
+ xs: 'px-2 py-1 px-button-x-xs py-button-y-xs text-xs rounded',
45
+ sm: 'px-2.5 py-1.5 px-button-x-sm py-button-y-sm text-sm rounded-md',
46
+ md: 'px-3 py-2 px-button-x py-button-y text-sm rounded-md',
47
+ lg: 'px-3.5 py-2.5 px-button-x-lg py-button-y-lg text-sm rounded-md',
48
48
  }
49
49
 
50
50
  const contentLayout = `w-full gap-x-1.5 ${iconPosition == 'none' ? '' : 'inline-flex items-center justify-center'}`
@@ -57,7 +57,7 @@ export function Button({
57
57
  }
58
58
 
59
59
  return (
60
- <button class={twMerge(`${base} ${colors[color]} ${sizes[size]} ${contentLayout} ${loading} ${className||''}`)} {...props}>
60
+ <button class={twMerge(`${base} ${colors[color]} ${sizes[size]} ${contentLayout} ${loading} nitro-button ${className||''}`)} {...props}>
61
61
  {IconLeft && getIcon(IconLeft)}
62
62
  {IconLeftEnd && getIcon(IconLeftEnd)}
63
63
  <span class={`${iconPosition == 'leftEnd' || iconPosition == 'rightEnd' ? 'flex-1' : ''}`}>{children}</span>
@@ -83,7 +83,7 @@ export function Calendar({ mode='single', onChange, value, numberOfMonths, month
83
83
  range_middle: `${d.range_middle} rangemiddle`,
84
84
  },
85
85
  classNames: {
86
- root: `${d.root} flex`,
86
+ root: `${d.root} flex nitro-calendar`,
87
87
  months: `${d.months} flex-nowrap`,
88
88
  month_caption: `${d.month_caption} text-2xs pl-2`,
89
89
  caption_label: `${d.caption_label} z-auto`,
@@ -91,6 +91,7 @@ export const Dropdown = forwardRef(function Dropdown({
91
91
  (isHoverable ? ' is-hoverable' : '') +
92
92
  (isActive ? ' is-active' : '') +
93
93
  (!animate ? ' no-animation' : '') +
94
+ ' nitro-dropdown' +
94
95
  (className ? ` ${className}` : '')
95
96
  }
96
97
  onClick={(e) => e.stopPropagation()} // required for dropdowns inside row links
@@ -9,7 +9,7 @@ export function GithubLink({ filename }: { filename: string }) {
9
9
 
10
10
  return (
11
11
  // <a href={link}>Go to Github</a>
12
- <a href={link} className="fixed top-0 right-0">
12
+ <a href={link} className="fixed top-0 right-0 nitro-github">
13
13
  <GithubIcon />
14
14
  </a>
15
15
  )
@@ -20,6 +20,7 @@ export function Initials({ icon, isBig, isMedium, isSmall, isRound, className }:
20
20
  (isSmall ? ' is-small' : '') +
21
21
  (isRound ? ' is-round' : '') +
22
22
  (icon ? '' : ' is-empty') +
23
+ ' nitro-initials' +
23
24
  (className ? ' ' + className : '')
24
25
  }
25
26
  style={icon ? {backgroundColor: icon?.hex + '15', color: icon?.hex} : {}}
@@ -82,7 +82,7 @@ export function Message() {
82
82
  {/* Global notification live region, render this permanently at the end of the document */}
83
83
  <div
84
84
  aria-live="assertive"
85
- className="pointer-events-none fixed inset-0 flex items-end px-4 py-6 sm:items-start sm:p-6 z-20"
85
+ className="pointer-events-none fixed inset-0 flex items-end px-4 py-6 sm:items-start sm:p-6 z-20 nitro-message"
86
86
  >
87
87
  <div className="flex w-full flex-col items-center space-y-4 sm:items-end">
88
88
  {/* Notification panel, dynamically insert this into the live region when it needs to be displayed */}
@@ -64,7 +64,7 @@ export function Modal({ show, setShow, children, maxWidth, minHeight, dismissabl
64
64
  return (
65
65
  <div
66
66
  onClick={(e) => e.stopPropagation()}
67
- class={`fixed top-0 w-[100vw] h-[100vh] z-[700] ${_state.root}`}
67
+ class={`fixed top-0 w-[100vw] h-[100vh] z-[700] nitro-modal ${_state.root}`}
68
68
  >
69
69
  <div class={`!absolute inset-0 box-content bg-gray-500/70 transition-opacity ${_state.bg}`}></div>
70
70
  <div class={`relative h-[100vh] overflow-y-auto transition-[opacity,transform] ${_state.container}`}>
@@ -27,7 +27,7 @@ export function Sidebar({ Logo, menu, links }: SidebarProps) {
27
27
  return (
28
28
  <>
29
29
  {/* mobile sidebar opened */}
30
- <Dialog open={sidebarOpen} onClose={setSidebarOpen} className="relative z-50 lg:hidden">
30
+ <Dialog open={sidebarOpen} onClose={setSidebarOpen} className="relative z-50 lg:hidden nitro-sidebar">
31
31
  <DialogBackdrop
32
32
  transition
33
33
  className="fixed inset-0 bg-gray-900/80 transition-opacity duration-300 ease-linear data-[closed]:opacity-0"
@@ -11,7 +11,7 @@ type TooltipProps = {
11
11
 
12
12
  export function Tooltip({ text, children, className, classNamePopup, isSmall }: TooltipProps) {
13
13
  return (
14
- <div class={`${className} relative inline-block align-middle`} css={style}>
14
+ <div class={`${className} relative inline-block align-middle nitro-tooltip`} css={style}>
15
15
  {
16
16
  text
17
17
  ? <>
@@ -8,7 +8,7 @@ type TopbarProps = {
8
8
 
9
9
  export function Topbar({ title, subtitle, submenu, btns, className }: TopbarProps) {
10
10
  return (
11
- <div class={`flex justify-between items-end mb-6 ${className||''}`}>
11
+ <div class={`flex justify-between items-end mb-6 nitro-topbar ${className||''}`}>
12
12
  <div class="flex flex-col min-h-12">
13
13
  { subtitle && <div class="py-2 text-sm">{subtitle}</div>}
14
14
  <div class="flex items-center py-2">
@@ -32,7 +32,7 @@ export function Checkbox({ name, id, size='sm', subtext, text, type='checkbox',
32
32
  const _size = sizeMap[size]
33
33
 
34
34
  return (
35
- <div className={`mt-input-before mb-input-after flex gap-3 ${props.className || ''}`}>
35
+ <div className={`mt-2.5 mb-6 mt-input-before mb-input-after flex gap-3 nitro-checkbox ${props.className || ''}`}>
36
36
  <div className="flex shrink-0 mt-[2px]">
37
37
  {
38
38
  type !== 'toggle'
@@ -99,7 +99,7 @@ export function Drop({ awsUrl, className, id, name, onChange, multiple, state, .
99
99
  // }
100
100
 
101
101
  return (
102
- <div class={`mt-input-before mb-input-after ${className || ''}`}>
102
+ <div class={`mt-2.5 mb-6 mt-input-before mb-input-after nitro-field nitro-drop ${className || ''}`}>
103
103
  <input
104
104
  {...props}
105
105
  id={inputId}
@@ -148,7 +148,7 @@ export function FieldCurrency({ config, currency='nzd', onChange, value, default
148
148
  defaultValue={defaultValue}
149
149
  />
150
150
  <span
151
- class={`absolute top-[1px] bottom-0 left-3 inline-flex items-center select-none text-gray-500 text-sm sm:text-sm/6 ${dollars !== null && settings.prefix == '$' ? 'text-dark' : ''}`}
151
+ class={`absolute top-[1px] bottom-0 left-3 inline-flex items-center select-none text-gray-500 text-sm sm:text-sm/6 ${dollars !== null && settings.prefix == '$' ? 'text-foreground' : ''}`}
152
152
  >
153
153
  {settings.prefix || settings.suffix}
154
154
  </span>
@@ -46,7 +46,7 @@ export function Field({ state, icon, iconPos: ip, ...props }: FieldProps) {
46
46
  const iconPos = ip == 'left' || (type == 'color' && !ip) ? 'left' : 'right'
47
47
 
48
48
  if (!props.name) {
49
- throw new Error('Input component requires a `name` prop')
49
+ throw new Error('Field component requires a `name` prop')
50
50
  }
51
51
 
52
52
  // Input type
@@ -58,7 +58,7 @@ export function Field({ state, icon, iconPos: ip, ...props }: FieldProps) {
58
58
  if (props.value) value = props.value as string
59
59
  else if (typeof state == 'object') value = util.deepFind(state, props.name) ?? ''
60
60
 
61
- // Errors: find any that match this input path
61
+ // Errors: find any that match this field path
62
62
  for (const item of (state?.errors || [])) {
63
63
  if (util.isRegex(props.name) && (item.title || '').match(props.name)) error = item
64
64
  else if (item.title == props.name) error = item
@@ -126,22 +126,26 @@ export function Field({ state, icon, iconPos: ip, ...props }: FieldProps) {
126
126
 
127
127
  function FieldContainer({ children, className, error }: { children: React.ReactNode, className?: string, error?: Error }) {
128
128
  return (
129
- <div css={style} className={`mt-input-before mb-input-after grid grid-cols-1 ${className || ''}`}>
129
+ <div css={style} className={`mt-2.5 mb-6 mt-input-before mb-input-after grid grid-cols-1 nitro-field ${className || ''}`}>
130
130
  {children}
131
- {error && <div class="mt-1.5 text-xs text-danger">{error.detail}</div>}
131
+ {error && <div class="mt-1.5 text-xs text-danger nitro-error">{error.detail}</div>}
132
132
  </div>
133
133
  )
134
134
  }
135
135
 
136
136
  function getInputClasses({ error, Icon, iconPos, type }: { error: Error, Icon?: React.ReactNode, iconPos: string, type?: string }) {
137
- const paddingLeft = type == 'color' ? 'sm:pl-9 pl-9' : 'sm:pl-8 pl-8'
138
- const paddingRight = type == 'color' ? 'sm:pr-9 pr-9' : 'sm:pr-8 pr-8'
137
+ const pl = 'pl-3 pl-input-x'
138
+ const pr = 'pr-3 pr-input-x'
139
+ const py = 'py-2 py-input-y'
140
+ const plWithIcon = type == 'color' ? 'pl-9' : 'pl-8' // was sm:pl-8 pl-8, etc
141
+ const prWithIcon = type == 'color' ? 'pr-9' : 'pr-8'
139
142
  return (
140
- 'col-start-1 row-start-1 block w-full rounded-md bg-white py-2 text-sm leading-[1.65] outline outline-1 -outline-offset-1 ' +
143
+ `block ${py} col-start-1 row-start-1 w-full rounded-md bg-white text-sm leading-[1.65] outline outline-1 -outline-offset-1 ` +
141
144
  'placeholder:text-input-placeholder focus:outline focus:outline-2 focus:-outline-offset-2 ' +
142
- (iconPos == 'right' && Icon ? `${paddingRight} pl-3 ` : (Icon ? `${paddingLeft} pr-3 ` : 'px-3 ')) +
145
+ (iconPos == 'right' && Icon ? `${pl} ${prWithIcon} ` : (Icon ? `${plWithIcon} ${pr} ` : `${pl} ${pr} `)) +
143
146
  (error ? 'text-red-900 outline-danger focus:outline-danger ' : 'text-input outline-input-border focus:outline-primary ') +
144
- (iconPos == 'right' ? 'justify-self-start ' : 'justify-self-end ')
147
+ (iconPos == 'right' ? 'justify-self-start ' : 'justify-self-end ') +
148
+ 'nitro-input'
145
149
  )
146
150
  }
147
151
 
@@ -18,7 +18,7 @@ export function FormError({ state, fields, className }: FormError) {
18
18
  return (
19
19
  <>
20
20
  {error ? (
21
- <div class={`text-danger mt-1 text-sm ${className||''}`}>
21
+ <div class={`text-danger mt-1 text-sm nitro-error ${className||''}`}>
22
22
  {error.detail}
23
23
  </div>
24
24
  ) : null}
@@ -58,7 +58,7 @@ export function Select({ inputId, minMenuWidth, name, prefix='', onChange, optio
58
58
  }
59
59
 
60
60
  return (
61
- <div css={style} class="mt-input-before mb-input-after">
61
+ <div css={style} class="mt-2.5 mb-6 mt-input-before mb-input-after nitro-select">
62
62
  <ReactSelect
63
63
  /**
64
64
  * react-select prop quick reference (https://react-select.com/props#api):
@@ -241,7 +241,7 @@ const selectStyles = {
241
241
  focus: 'outline-2 -outline-offset-2 outline-primary',
242
242
  error: 'outline-danger',
243
243
  },
244
- valueContainer: 'py-2 px-3 gap-1',
244
+ valueContainer: 'py-2 px-3 py-input-y px-input-x gap-1',
245
245
  // Input container objects
246
246
  input: {
247
247
  base: 'text-input',
@@ -249,7 +249,7 @@ const selectStyles = {
249
249
  },
250
250
  multiValue: 'bg-primary text-white rounded items-center pl-2 pr-1.5 gap-1.5',
251
251
  multiValueLabel: '',
252
- multiValueRemove: 'border border-black/10 bg-clip-content bg-white rounded-md text-dark hover:bg-red-50',
252
+ multiValueRemove: 'border border-black/10 bg-clip-content bg-white rounded-md text-foreground hover:bg-red-50',
253
253
  placeholder: 'text-input-placeholder',
254
254
  singleValue: {
255
255
  base: 'text-input',
@@ -11,7 +11,7 @@ export function Toggle({ name, id, subtext, text, type='checkbox', ...props }: T
11
11
  id = id || name
12
12
  // https://tailwindui.com/components/application-ui/forms/checkboxes#component-744ed4fa65ba36b925701eb4da5c6e31
13
13
  return (
14
- <div className={`mt-input-before mb-input-after flex gap-3 ${props.className || ''}`}>
14
+ <div className={`mt-2.5 mb-6 mt-input-before mb-input-after flex gap-3 nitro-toggle ${props.className || ''}`}>
15
15
  <div className="flex h-6 shrink-0 items-center">
16
16
  <div className="group grid size-4 grid-cols-1">
17
17
  <input
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-web",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "repository": "github:boycce/nitro-web",
5
5
  "homepage": "https://boycce.github.io/nitro-web/",
6
6
  "description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
File without changes