@robust-ui/tools
v1.3.0
Published
Tools for Robust UI
Downloads
3
Readme
@robust-ui/tools / Exports
Robust
Robust is a system for generating React components with real-time CSS injection. It is programmed in TypeScript, providing type safety and enhanced developer experience.
Project Stats
Installation
You can install Robust using either npm or pnpm. To do this, run one of the following commands:
Using npm:
npm install @robust-ui/core
Using pnpm:
pnpm install @robust-ui/core
using yarn:
yarn add @robust-ui/core
Alternatively, you can also download Robust from the GitHub repository and manually install the dependencies. The prepare script defined in the package.json file will automatically build all the files within the packages folder.
Usage
To use Robust, you need to make use of the Main
component from the @robust-ui/nextjs-components
repository. Note that the functionality has only been tested with Next.js and may not work in other React environments.
Here's an example of how to use Robust in a Next.js application:
import { Main, Header, Text, Icon, Flex } from "@robust-ui/nextjs-components";
import { SideMenu } from "@/components/drawer";
import type { AppProps } from "next/app";
import React from "react";
export default function App({ Component, pageProps }: AppProps) {
const [open, setOpen] = React.useState(false);
return (
<Main color="white" fontFamily="Fira Code">
<Header backgroundColor="gunMetal">
<Flex>
<Text fontWeight="700" fontSize="1.5rem">
Nahuel
</Text>
</Flex>
<Icon type="menu" onClick={() => setOpen(!open)} />
</Header>
<SideMenu open={open} setOpen={setOpen} />
<Component {...pageProps} />
</Main>
);
}
In the above example, we import the necessary components from Robust and use them to create a basic application structure. The Main
component sets the color and font family for the components. The Header
component represents the application header, including a title and a menu icon that toggles the open
state. The SideMenu
component displays a side drawer with links and language options. Finally, we render the Component
with the pageProps
.
Please note that this usage example is specific to Next.js, and the functionality may not be tested or supported in other React environments. Make sure to customize the components and their properties based on your specific requirements.
Features
Robust includes the following features:
- Automatic responsiveness: The components are designed to adapt to different screen sizes and orientations.
- Quick language switching: Easily switch between different languages using the language options provided.
- Dark mode: The system supports a dark mode theme that can be enabled or disabled.
- Global states: Robust provides mechanisms for managing global states and sharing data between components.
- Real-time CSS injection: The system injects CSS in real time, allowing for dynamic styling and theming.
- TypeScript support: Robust is programmed in TypeScript, providing type safety and enhanced developer experience.
- Customizable components: The components can be customized using various properties to suit your specific requirements.
- Easy to use: Robust is designed to be easy to use and integrate with existing React applications.
- Extensible: The system can be extended with additional components and functionality as needed.
- Well-documented: The codebase is well-documented, making it easy to understand and contribute to.
- Active development: Robust is actively developed and maintained, with regular updates and improvements.
Contributing
Contributions to Robust are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.
License
Robust is released under the MIT License.
Interfaces
@robust-ui/tools / Exports / IOptions
Interface: IOptions
Table of contents
Properties
Properties
digest
• digest: BinaryToTextEncoding
Defined in
hashAlgorithm
• hashAlgorithm: string
Defined in
iterations
• iterations: number
Defined in
pepper
• Optional
pepper: string
Defined in
salt
• Optional
salt: string
Defined in
@robust-ui/tools / Exports
@robust-ui/tools
Table of contents
Interfaces
Type Aliases
Functions
- attributeCompleter
- debounce
- generateHash
- generateUniqueId
- isEmptyArray
- isEmptyObject
- isNullOrUndefined
- normalizeInputKey
- propagation
- propsSplitter
- safeJSON
- stopPropagation
- valueRecoverer
Type Aliases
PartialRecord
Ƭ PartialRecord<T
, U
>: Partial
<Record
<T
, U
>>
Type parameters
| Name | Type |
| :--- | :--------------- |
| T
| extends string
|
| U
| U
|
Defined in
attribute-completer/index.ts:1
Functions
attributeCompleter
▸ attributeCompleter(«destructured»
): Partial
<Record
<string
, unknown
>> | undefined
Completes the attributes object by filling in missing values based on the provided input attributes and media breakpoints. Throws an error if the input attributes are invalid.
Parameters
| Name | Type |
| :------------------- | :------------------------------ |
| «destructured»
| Object
|
| › inputAttributes
| Record
<string
, unknown
> |
| › mediaBreakpoints
| Record
<string
, number
> |
Returns
Partial
<Record
<string
, unknown
>> | undefined
The completed attributes object or undefined if there are no attributes to complete.
Throws
Error if the input attributes are missing or have an invalid format.
Defined in
attribute-completer/index.ts:13
debounce
▸ debounce<T
>(options
): (this
: unknown
, ...args
: Parameters
<T
>) => void
| undefined
Creates a debounced function that delays invoking the provided function until after a specified delay.
Type parameters
| Name | Type | Description |
| :--- | :----------------------------------------- | :------------------------------------ |
| T
| extends (...args
: unknown
[]) => void
| The type of the function to debounce. |
Parameters
| Name | Type | Default value | Description |
| :------------------- | :-------- | :------------ | :------------------------------------------------------------------------------------------ |
| options
| Object
| undefined
| The options for the debounced function. |
| options.delay?
| number
| 0
| The delay in milliseconds before invoking the debounced function. |
| options.fn
| T
| undefined
| The function to debounce. |
| options.immediate?
| boolean
| false
| Specifies whether the debounced function should be invoked immediately on the leading edge. |
Returns
(this
: unknown
, ...args
: Parameters
<T
>) => void
| undefined
- The debounced function.
Defined in
generateHash
▸ generateHash(«destructured»
): string
Generates a hash for the given input string using the specified options.
Parameters
| Name | Type |
| :--------------- | :---------------------------------- |
| «destructured»
| Object
|
| › inputString
| string
|
| › options?
| IOptions
|
Returns
string
The generated hash as a string.
Throws
Error if an invalid hash algorithm or digest format is provided.
Defined in
generateUniqueId
▸ generateUniqueId(«destructured»
): string
Generates a unique ID based on the provided object, prefix, and options. If the object is a string, it will be used directly. Otherwise, it will be converted to a JSON string. The generated ID is a hash of the input string using the specified hash algorithm and digest. If a prefix is provided, it will be prepended to the generated ID.
Parameters
| Name | Type |
| :--------------- | :---------------------------------- |
| «destructured»
| Object
|
| › object
| unknown
|
| › options?
| IOptions
|
| › prefix?
| string
|
Returns
string
The generated unique ID.
Throws
Error if unable to generate an ID from the input.
Defined in
generate-unique-id/index.ts:16
isEmptyArray
▸ isEmptyArray(arr
): boolean
Checks if an array is empty.
Parameters
| Name | Type | Description |
| :---- | :---------- | :------------------ |
| arr
| unknown
[] | The array to check. |
Returns
boolean
True if the array is empty, false otherwise.
Defined in
isEmptyObject
▸ isEmptyObject(obj
): boolean
Checks if an object is empty.
Parameters
| Name | Type | Description |
| :---- | :------- | :------------------- |
| obj
| object
| The object to check. |
Returns
boolean
True if the object is empty, false otherwise.
Defined in
isNullOrUndefined
▸ isNullOrUndefined(value
): boolean
Checks if a value is null or undefined.
Parameters
| Name | Type | Description |
| :------ | :-------- | :------------------ |
| value
| unknown
| The value to check. |
Returns
boolean
True if the value is null or undefined, false otherwise.
Defined in
normalizeInputKey
▸ normalizeInputKey(«destructured»
): Object
Normalizes the input key by removing the specified keyword and converting it to the desired output format. Throws an error if the input key is invalid or no valid prop name is found.
Parameters
| Name | Type | Default value |
| :--------------- | :---------------------------------------------- | :------------ |
| «destructured»
| Object
| undefined
|
| › inputKey
| string
| undefined
|
| › keyword?
| string
| "raw"
|
| › outputKey?
| "camelCase"
| "snakeCase"
| "kebabCase"
| "camelCase"
|
Returns
Object
An object containing the information about whether the keyword is present in the input key and the normalized output key.
| Name | Type |
| :----------------- | :-------- |
| isKeywordPresent
| boolean
|
| output
| string
|
Throws
Error if the input key is invalid or no valid prop name is found.
Defined in
normalize-input-key/index.ts:11
propagation
▸ propagation(«destructured»
): ReactNode
[] | null
| undefined
Propagates HTML attributes to all valid React elements in the children tree.
Parameters
| Name | Type |
| :--------------- | :-------------------------------- |
| «destructured»
| Object
|
| › children
| ReactNode
|
| › props
| HTMLAttributes
<HTMLElement
> |
Returns
ReactNode
[] | null
| undefined
The updated ReactNode with the propagated attributes.
Defined in
propsSplitter
▸ propsSplitter(«destructured»
): Object
Splits the props into HTML props and style props based on the provided commands.
Parameters
| Name | Type |
| :--------------- | :-------------------- |
| «destructured»
| IpropsSplitterProps
|
Returns
Object
An object containing the HTML props and style props.
| Name | Type |
| :----------- | :------------------------------ |
| htmlProps
| Record
<string
, unknown
> |
| styleProps
| Record
<string
, unknown
> |
Defined in
safeJSON
▸ safeJSON(«destructured»
): string
| undefined
Safely converts an object to a JSON string representation.
Parameters
| Name | Type |
| :-------------------- | :------------------------------------------------- |
| «destructured»
| Object
|
| › indentation?
| string
| number
|
| › object
| unknown
|
| › replacerFunction?
| (key
: string
, value
: unknown
) => unknown
|
Returns
string
| undefined
The JSON string representation of the object, or undefined if an error occurs.
Throws
Error if unable to stringify the object.
Defined in
stopPropagation
▸ stopPropagation(children
): undefined
| null
| (string
| number
| ReactElement
<any
, string
| JSXElementConstructor
<any
>> | Iterable
<ReactNode
>)[]
Stops the propagation of click events on the provided React children elements.
Parameters
| Name | Type | Description |
| :------------------ | :---------- | :--------------------------- |
| children
| Object
| The React children elements. |
| children.children
| ReactNode
| - |
Returns
undefined
| null
| (string
| number
| ReactElement
<any
, string
| JSXElementConstructor
<any
>> | Iterable
<ReactNode
>)[]
The modified React children elements with click event propagation stopped.
Defined in
valueRecoverer
▸ valueRecoverer(«destructured»
): unknown
| undefined
Recovers the value based on the provided input properties and values.
Parameters
| Name | Type |
| :------------------------- | :----------------------------------- | ------------------------ |
| «destructured»
| Object
|
| › breakPoints
| Object
|
| › breakPoints.context
| Record
<string
, unknown
> |
| › breakPoints.current
| string
|
| › currentGlobalLanguage?
| string
|
| › darkMode
| boolean
|
| › inputProp
| string
|
| › inputValue
| unknown
|
| › isRaw?
| boolean
|
| › theme
| Record
<string
, { [key: string | number]
: unknown
; }> |
Returns
unknown
| undefined
The recovered value.