I, your God, command you to follow these guidelines religiously.
All change events on interactive shall provide the most relevant value of the component as the first argument. The change event object shall be provided as the second argument. This is only required for the most relevant change event (usually React.ChangeEvent), it is not required for React.InputEvent, for example.
Normal JavaScript events shall always be propagated. For example, if you're using onBlur within a component, this event must also be propagated with a prop. Example:
const Dropdown: React.FC<DropdownProps> = ({ ..., onBlur }) => {
function handleBlur(evt: React.FocusEvent<HTMLInputElement>) {
// Do something
onBlur(evt) // This is required
}
return (
<Wrapper>
<Input ... onBlur={handleBlur} />
...
</Wrapper>
)
}
Prop interfaces and destrucutred props in component function definitions should be ordered and divided reasonably by category. Event callbacks should come last in the prop order. You should use the same order in the interface and the destructuring. Example:
interface DropdownProps<ValueType> {
value: ValueType
items: DropdownItem<ValueType>
color?: string
background?: string
onChange: (value: ValueType) => void
}
const Dropdown: React.FC<DropdownProps>({
value,
items,
color = 'black',
background = 'white',
onChange
}) => { ... }
The className
prop shall be available on all components, and injected at the most reasonable location. This is usually the top-most wrapper in the component.
You should strive to use a uniform naming convetion across components. For example, it's bad practice to name a prop color
in one component and foreColor
in another, of the purpose of both props is to set the color if the component text.
Whereever a component might have some hard coded inner text, this text should be configurable by prop. The default value of this prop should be in english. Example:
const Error: React.FC<ErrorProps> = ({ ..., message = 'An error occured' }) => {
return <ErrorWrapper>{message}</ErrorWrapper>
}
All components shall strive to use theme variables wherever prudent.
All subelements shall have class names prefixed with --
, for easier overriding of styles. These should be documented. Example:
<Wrapper className="{className}">
<ErrorMessage className="--error-message"> ... </ErrorMessage>
</Wrapper>
Union litaral types are preferred wherever relevant. Example:
interface Props {
placement: string // No!
}
interface Props {
placement: 'above' | 'below' | 'left' | 'right' // Yes!
}
export type Placement = 'above' | 'below' | 'left' | 'right'
interface Props {
placement: Placement // Premium pornography
}
In interactive components with values, normally form inputs, generic props whould be used when reasonable. Example
interface DropdownProps {
value: number
onChange: (value: number) => void
}
interface DropdownProps<ValueType> {
value: ValueType
onChange: (value: ValueType) => void
}
This will not be the case for every form input of course, for example the <input />
component will probably always use a string as a value.
- Package
- Change package name to
@ur-solutions/react-components
- Change package name to
- Card
- Add
ref
to Card component
- Add
- NumberInput
- Fix .020 error
- NumberInput
- Fix bug when writing negative numbers
- Remove errant unicode symbol
- Select
- Add
--select-curtain-option-selected
class for selected option
- Add
- DropdownMenu
- Add
side
prop- Choose which side of the trigger the menu should be placed
- Add
- Select
- Add className
--select-curtain-option-active
to active select option
- Add className
- Input
- Ensure displayed input value is always up to date with
value
- Ensure displayed input value is always up to date with
- VippsLoginButton
- Add VippsLoginButton component
- NumberInput
- Add
clearable
prop, which allows clearing the input - Add
onCleared
event, which is fired when input is cleared ifclearable
istrue
- Add
- NumberInput
- Fix dumb bug where you couldn't write a lone zero immediately after a decimal point
- DatePicker & TimePicker
- Applies v0.16.2-patch1 changes
- Input
- Add property 'rightLabel'
- Loader
- Add Spinner type
wheel
- Add Spinner type
- Stable release
- Switch from
react-spring
andreact-use-gesture
toframer-motion
- Remove
FilePicker
andFilePickerButton
components - ImageViewer
- Add
showDownloadButton
prop - Deprecate
noShadow
andpadding
props
- Add
- Icon
- Upgrade to FontAwesome v6
- Export FontAwesome types
- Upgrade to React 18
- Select and SelectMultiple
- Forward refs to components, with
toggleOpen
function - Add
clickOutsideExclude
prop- If an element in this array is clicked, curtain is not closed even though element is outside of curtain
- Forward refs to components, with
- PrivateRoute
- Add PrivateRoute component
- With PrivateRouteProvider
- Supports checking if user is authenticated and authorized to access route
- Requires
react-router-dom
- Add PrivateRoute component
- Input
- Add
runAutoCompleteOnFocus
prop- Runs autocomplete function/shows list on focus
- Add
runAutoCompleteWithNoInput
prop- Runs autocomplete function/shows list also when there's no text in input
- Add
- ImageViewer
- Improve styling of navigation arrows
- TextArea
- Add
submitConfig.hint
prop- Displays hint text in lower left corner
- Add
- TextArea
- Add
onSubmit
event- Adds a submit icon to lower right of TextArea
- Add
onCtrlEnter
event
- Add
- Input
- Fix bug where
onEnter
event did not fire
- Fix bug where
- Prompt
- Fix bug where prompt config was inherited from previous prompts
- ActionButton
- Add prop
to
- Define a path/location description to act as link
- Add prop
role
- Make
onClick
optional
- Add prop
- Input
- Add event
onEnter
- Fired when Enter key is pressed
- Add event
- ActionButton
- Add ref
- DatePicker
- Added
onCleared
explicit API prop toDatePickerProps
and component.
- Added
- TimePicker
- Added
disabled
prop toTimePickerProps
and component.
- Added
- Prompt
- Fix typing issue in
addPrompt
return
- Fix typing issue in
- Toast
- Make it possible to set
progressBarColor
per toast type
- Make it possible to set
- Prompt (BREAKING)
- Add
closeOnResolve
prompt option- Set to false to not close prompt on resolve. Default true
- Add
close
return func toaddPrompt
- Use to close prompt manually
- Add
update
return func toaddPrompt
- Use to update state of prompt from the outside. Required that the
id
variable, given in thirdaddPrompt
callback parameter, is added as prop to custom prompt
- Use to update state of prompt from the outside. Required that the
- Add
usePromptState
hook- Gets local state for current prompt. Is passed the
id
prop from previous point
- Gets local state for current prompt. Is passed the
- Add
- Toast (potentially breaking)
- Set
icons
or specific icons within tonull
to not show an icon in the Toast -
contentAlignVertical
set to defaultcenter
- Set
- RadioGroup
- Add
className
prop - Add
className
to radio wrapper
- Add
- Prompt
- Add
closeOnClickOutside
andcloseOnEscape
to prompt optionsmodalProps
- If enabled, click outside/escape will reject promise with reason arg set to -1
- Add
- Input
- Add
loading
prop- Displays a loader in the
Input
- Displays a loader in the
- Add
- Checkbox
- Bugfix: correctly handle
disabled
- Bugfix: correctly handle
- Toast
- Add option
color
per toast type - Add option
box-shadow
- Add option
- FilePicker & FilePickerButton
-
accept
property now accepts file extensions matched against filename (.png, .csv, .mp3 etc)
-
- Input
-
type
property now supports all listed types from MDN's<input>
types
-
-
react-spring
upgraded to 9.1.1- This may be breaking if project uses older version/realease candidate
-
storybook
fixed
- Input
- Add
onAutoCompleteItemSelect
event
- Add
- Select and SelectMultiple
- Add
onCurtainScroll
event
- Add
- Breadcrumbs
- Add
ref
to Breadcrumbs and RouteBreadcrumbs
- Add
- DatePicker and DateRangePicker
- Add
height
prop
- Add
- DatePicker and DateRangePicker
- Add
noAnimation
prop- Disables curtain animation
- Add
- Input
- Add
selectOnFocus
-prop- Selects text in input when focused
- Also available in
NumberInput
- Add
- Modal
- Add props
shouldFocusAfterRender
andshouldReturnFocusAfterClose
fromreact-modal
- Add props
- Checkbox
- Fix Checkbox
tabIndex
- Add
onKeyDown
checkbox event and toggle on Enter and Space keys
- Fix Checkbox
- RouteBreadCrumbs
- Add
inserts
prop- Allows for inserting custom crumbs in RouteBreadcrumbs
- Add
- Input
- Add
name
andautoCompelete
props
- Add
- Upgrade to React 17
- Checkbox
- Add
boxSize
prop- Set both
width
andheight
at once
- Set both
- Add
- Tooltip
- Add Tooltip component
- Modal
- Add
noShade
prop to modal
- Add
- NumberInput
- Bugfix: disable mouse wheel when input is disabled
- NumberInput
- Fix bug where an extra decimal place was added when removing a decimal number
- NumberInput
- Adds NumberInput component
- Input which only accepts numbers (duh)
- Adds NumberInput component
- Prompt
- Add
modalProps
to prompt options
- Add
- Prompt
- Adds Prompt component
- Comes with
PromptProvider
, which must be added somewhere in project root (within theme provider) - Works through
usePrompt
hook -
usePrompt
hooks returnsaddPrompt
function, which again will return a promise ofboolean
or custom-defined type - Let's you define custom prompt, or use built-in "Cancel"/"Confirm" prompt
- Comes with
- Adds Prompt component
- TimePicker
- Add props
width
,maxWidth
andminWidth
- Add props
- TimePicker
- Fix error in background color
- And add classNames to sub-comps
- Select & SelectMultiple
- Add custom filtering to Select
- Set
searchable
tocustom
and use new eventonFilterChange
to handle searching
- Set
- Add custom filtering to Select
- DatePicker
- Make DatePicker clearable
- Add props
clearable
andinitCleared
, which makes it possible to clear DatePicker content - Second argument of
onChange
is nowcleared
, which will betrue
ifclearable
istrue
and input text is empty. First argument will still be currently selected date. - Also adds a ref, which contains a
clear
-method
- Add props
- Make DatePicker clearable
- Breadcrumbs & RouteBreadcrumbs
- Add ability to hide crumbs
- Input
- Add
email
andurl
types
- Add
- ImageViewer
- Add prop
noShadow
- Add prop
- ImageViewer
- Add prop
popup
and related props- Display image viewer as a popup
- Add prop
- Switch to relative imports
- Loader
- Add Dots loader
- Type
ellipsis
- Type
- Add Dots loader
- RuoteBreadcrumbs
- Fix bug where crumbs didn't update on route change
- Breadcrumbs
- Add props
color
andclassName
to Crumb - RouteBreadcrumbs: Add prop
overrideCrumb
- Let's you override individual crumbs
- Add props
- Dependencies
- Upgrade react-use-gesture to 8.0.0, and update peerDependencies
- Input
- Add
errorOffsetX
anderrorOffsetY
props- Set an offset for the error message position
- Add
className
to input error wrapper--input-error
- Add
- Select
- Change behavior of arrow keys
- If curtain not open, cycle options
- Change behavior of arrow keys
- Icon
- Add
duotone
type - Add
swapOpacity
prop
- Add
- Badge
- Add props
className
andid
- Add props
translateTextX
andtranslateTextY
- Add prop
border
- Add props
boxShadow
andnoShadow
- Add prop
enablePointerEvents
- Remove default from prop
minWidth
- Add props
- TextArea
- Add
autoFocus
property
- Add
- DatePicker
- Bugfix: display was not updated when
value
was updated externally
- Bugfix: display was not updated when
- DatePicker
- Add
closeOnDateChange
prop- Close curtain on date change, default false
- Add
- Select & SelectMultiple
- Add error props to Selects
- Same functionality as on Input component
- Input
- Add
hideErrorMessage
prop
- Add
- Input
- Add
textAlign
prop
- Add
- Select & SelectMultiple
- Add
minWidth
andmaxWidth
props
- Add
- Input
- Make
disabled
prop actually work
- Make
- TextArea
- Add
disabled
prop
- Add
- Select and SelectMultiple
- Add option as argument to Select and SelectMultiple
onChange
event
- Add option as argument to Select and SelectMultiple
- DateRangePicker
- Implement better range handling and styling
- DatePicker and DateRangePicker
- Add
keepOpen
prop- Keeps DatePicker always open.
- Add
focusBorderColor
prop
- Add
- Input
- Add
focusBorderColor
prop
- Add
- DateRangePicker
- Add component DateRangePicker
- Very unfinished, but I need it now
- Add component DateRangePicker
- Toggle
- Add
disabled
prop to Toggle - Add
disabledBackground
prop to Toggle - Add
onKeyDown
prop to Toggle- Also listen for arrow keys and enter/space
- Add
- Select
- Bugfix in arrow/enter key open
- Select
- Add
disabled
prop to Select and MultiSelect
- Add
- ThumbnailList
- Add
altRender
prop- Altarnate render function in case an image doesn't load
- Add
- Package upgrades
- Select
- Add
nullable
prop to Select- Makes it possible to clear selected value
- Some UX fixes
- Scroll into view on arrow key navigation
- Open select on enter/down arrow
- Add
- Select
-
className
fixes
-
- Thumbnail
- Add border props
- ThumbnailList
- Add component
- Select
- Make it possible to define a custom function for
searchable
prop
- Make it possible to define a custom function for
- Error fixes
- Modal
- Add
react-modal
- Add
onClose
prop- If
onShadeClick
isundefined
,onClose
is used in its placement
- If
- Add
closeOnEscape
prop
- Add
- Error fixes
- RadioGroup
- Fix key prop in radio item list
- Input
- Add maxLength prop
- Select
- Add iconProps prop for arrow icon styling
- Set Select and SelectMultiple inline prop to default
false
- DatePicker
- Set
z-index: 1
on curtain
- Set
- Button
- Add autoFocus property
- Add centerContent property (centers content if
width
is notauto
)
- Add UrThemeProvider
- Export typings
- Initial release