3.0.0-beta-v0.17 • Published 10 months ago

mobrix-ui-beta v3.0.0-beta-v0.17

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

MoBrix-ui

Smart React components for every app, easily customizable for every purpose.

NPM npm (scoped) npm bundle size (scoped) Maintenance tested with jest


Status

Codacy grade Codacy coverage Code Climate technical debt Code Climate issues Code Climate coverage Coveralls Codecov


:exclamation:

Note for MoBrix-ui v1 user

MoBrix-ui v2 introduces some breaking changes that makes it not compatible with older MoBrix verions (using different lib versions in parallel is possible, but can cause some unexpected errors). If you are using MoBrix 1.X.X, please read the dedicated guide, or upgrade it to v3.X.X!

Note for MoBrix-ui v2 user

MoBrix-ui v3 introduces some breaking changes that makes it not compatible with older MoBrix verions (using different lib versions in parallel is possible, but can cause some unexpected errors). If you are using MoBrix 2.X.X, please read the dedicated guide, or upgrade it to v3.X.X!


Summary



MoBrix-ui philosophy

This library is built upon few (but important) concepts:

  • Small library size, to not impact on final app bundle size
  • Few dependencies, to not introduce a bunch of additional packages (that could also introduce bugs or version conflicts with pre-existent packages)
  • Let the user customize every part as desired, but with default values set otherwise, to make every component ready to be used without so many parameters
  • Every component should be integrable into every react app, so their behaviour must be customizable too (with callbacks, for example)

The same concepts are also the base of another project I maintain, MoBrix-engine (check it out, it is also the base of MoBrix-ui guide page !)



Components building process

This library use a standardized process to build every component. As result, every component has a shared initial logic, shared CSS styles and shared properties. Some properties are shared between all components, for a smoother dev experience. In addition, this makes every single component easily re-usable.


UI properties

PropertyTypeDescriptionDefault value
classNamestringcustom className applied on main container""
darkbooleanEnable/disable dark modefalse
hidebooleanHide/show componentfalse
idstringdata-id parameter (for testing purpose, to easily find the component into the DOM)/
shadowbooleanEnable/disable shadow behind componentfalse
styleRecord<string,any>Css inline properties applied on main container/
unstyledbooleanIf true, no standard mobrix-ui styles will be applied on the components (useful for example, with image buttons)false
animatedbooleanEnable/disable component animationsfalse

Accessibility properties

Some accessibility properties are shared between all components, for a better and smoother user experience, in any scenario:

PropertyTypeDescriptionDefault value
onFocus( ) => voidcustom callback triggered when the component get the focus (for example, through tab key)/
onFocusLost( ) => voidcustom callback triggered when the component lose the focus (for example, when user clicks outside it)/
a11ybooleanEnable/disable accessibility features.true
a11yLabelstringIf a11y = true, is used as aria-label accessibility parameter/
a11yDarkbooleanIf a11y = true, enable/disable dark mode for a11y styles. If not set, will be used the dark UI parametersame as dark or false
onKeyDown(keyEvent : any) => voidcustom callback triggered when a key is pressed while using the component (for example, when writing text inside an Input component)./

CSS variables

MoBrix-ui is globally configurable, with CSS variables. By defining some specific custom CSS variables into your app css, you'll change the UI of all components:

CSS variableDescriptionDefault valueRelated CSS attribute
--mobrix-ui-custom-background-darkComponents background, when in dark-mode (dark is set to true).linear-gradient(to right, #2d3748, #1d232e)background-image
--mobrix-ui-custom-background-color-darkComponents background color, when in dark-mode (dark is set to true).#1d232ebackground-color
--mobrix-ui-custom-text-color-darkComponents text color, when in dark-mode (dark is set to true).whitetext-color
--mobrix-ui-custom-background-lightComponents background, when not in dark-mode (dark is set to false).linear-gradient(to right, #fff, #eaebec)background-image
--mobrix-ui-custom-background-color-lightComponents background color, when not in dark-mode (dark is set to false).#f5f5f5background-color
--mobrix-ui-custom-text-color-lightComponents text color, when not in dark-mode (dark is set to false).#1b1b1btext-color
--mobrix-ui-custom-focus-color-lightIf a11yDark = false , this color is used to update UI when a component is focused (with a screen reader or by navigating with the Tab key)#7785ffbox-shadow / color
--mobrix-ui-custom-focus-color-darkIf a11yDark = true , this color is used to update UI when a component is focused (with a screen reader or by navigating with the Tab key)#fb7a10box-shadow / color

Reactive components

Some components are designed with a specific structure, to sync their internal state with an external input value. This kind of component handle internally their actual value, using the value parameter as starting point. This let the component to be driven in 2 different way:

  • Internally, Its internal value, when using the component without changing its value parameter from code

  • External, passing the value parameter

So, we have 2 scenarios:

  • If you change the component value using the component(without changing the value parameter), it will be updated internally.

  • If you change the passed value parameter, the component will sync its value with the given one.

A clear example is the Input component. When changing the value parameter, the component will sync its actual value.



Getting started


Installation

If you want to use this library inside your project, just install it:

npm i mobrix-ui

Usage

After installation, you can use every MoBrix-ui component in your app. Run this example to see them in action:

import { Card, Container, Link } from "mobrix-ui";
import { render } from "react-dom";

render(
  <Container animated>
    <Card
      dark={true}
      body={<p>This page is entirely made with MoBrix-ui components !</p>}
      footer={
        <Link to="https://cianciarusocataldo.github.io/mobrix-ui">
          MoBrix-ui page
        </Link>
      }
    />
  </Container>,
  document.getElementById("root")
);

Edit MoBrix-ui playground

If you want to customize the UI globally, initialize the dedicated CSS variables:

* {
  --mobrix-ui-text-color: #f5f5f5;
  --mobrix-ui-background-color: #1b1b1b;
}


Tests

Unit tests for every component are located inside tests folder. The test script is executed with pre-defined test command:

npm run test

Authors


License

This project is licensed under the MIT License - see the LICENSE file for details

3.0.0-beta-v0.17

10 months ago

3.0.0-beta-v0.16

10 months ago

3.0.0-beta-v0.15

10 months ago

3.0.0-beta-v0.14

10 months ago

3.0.0-beta-v0.13

10 months ago

3.0.0-beta-v0.12

10 months ago

3.0.0-beta-v0.11

10 months ago

3.0.0-beta-v0.10

10 months ago

3.0.0-beta-v0.9

10 months ago

3.0.0-beta-v0.8

10 months ago

3.0.0-beta-v0.7

10 months ago

3.0.0-beta-v0.6

10 months ago

3.0.0-beta-v0.5

10 months ago

3.0.0-beta-v0.4

10 months ago

3.0.0-beta-v0.3

10 months ago

3.0.0-beta-v0.2

10 months ago

3.0.0-beta-v0.1

10 months ago

3.0.0

10 months ago