1.3.0 • Published 3 months ago

@robust-ui/css-utils v1.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

@robust-ui/css-utils / 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

Alt

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.


@robust-ui/css-utils / Exports

@robust-ui/css-utils

Table of contents

Functions

Functions

addOpacity

addOpacity(options): string

Adds opacity to a given color.

Parameters

NameTypeDescription
optionsObjectThe options for adding opacity.
options.colorstringThe color to add opacity to.
options.opacitynumberThe opacity value (between 0 and 1).

Returns

string

The color with added opacity in the RGBA format.

Throws

If the color format is invalid.

Defined in

colors-functions/index.ts:165


generateColorScheme

generateColorScheme(options): Object

Generates a color scheme based on the provided options.

Parameters

NameTypeDefault valueDescription
optionsObjectundefinedThe options for generating the color scheme.
options.baseColor?string"teal"-
options.complementaryColor?booleanfalse-
options.isActivated?booleantrue-
options.isDisabled?booleanfalse-
options.isInvalid?booleanfalse-
options.isValid?booleanfalse-
options.opacity?number0.7-
options.props?Objectundefined-
options.props.active?booleanundefined-
options.props.background?booleanundefined-
options.props.border?booleanundefined-
options.props.focus?booleanundefined-
options.props.hover?booleanundefined-
options.variantVariant"solid"-

Returns

Object

The generated color scheme.

Defined in

colors-functions/index.ts:282


generateContrastingColor

generateContrastingColor(baseColor): string

Generates a contrasting color based on the provided base color. The base color should be in the RGBA format. If the base color is not in the expected format, an error will be thrown. The contrast color is calculated by determining the grayscale value of the base color, and then setting the brightness to either 0 or 255 based on the grayscale value. The contrast alpha is calculated by multiplying the base alpha by 2.5, with a maximum value of 1.

Parameters

NameTypeDescription
baseColorstringThe base color in the RGBA format.

Returns

string

The contrasting color in the RGBA format.

Throws

Error if the base color is not in the expected format.

Defined in

colors-functions/index.ts:196


generateUniqueClassName

generateUniqueClassName(object): string | undefined

Generates a unique class name based on the provided object.

Parameters

NameTypeDescription
objectObjectThe object used to generate the unique class name.
object.objectObject-

Returns

string | undefined

The generated unique class name.

Throws

If an error occurs while generating the unique class name.

Defined in

generate-unique-classname/index.ts:10


getRandomHexColor

getRandomHexColor(): string

Generates a random hexadecimal color code.

Returns

string

A string representing a random hexadecimal color code.

Defined in

colors-functions/index.ts:269


injectStyle

injectStyle(options): { inputProps: Record\<string, unknown> ; styledCSSMap: Map\<string, string[]> } | undefined

Injects CSS styles based on the provided options.

Parameters

NameTypeDescription
optionsInjectCSSTOptionsThe options for injecting CSS styles.

Returns

{ inputProps: Record\<string, unknown> ; styledCSSMap: Map\<string, string[]> } | undefined

An object containing the styled CSS map and input props, or undefined.

Defined in

inject-style/index.ts:11

1.2.0

3 months ago

1.1.0

3 months ago

1.3.0

3 months ago

1.0.0

4 months ago

0.12.0

5 months ago

0.11.0

5 months ago

0.10.0

5 months ago

0.9.0

5 months ago

0.8.0

5 months ago

0.7.1

5 months ago

0.5.0

5 months ago

0.7.0

5 months ago

0.6.0

5 months ago

0.4.0

7 months ago

0.3.0

7 months ago

0.2.0

7 months ago

0.1.0

7 months ago

0.0.1

8 months ago