1.5.5 • Published 2 years ago

boxis-uikit v1.5.5

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Boxis UIKit

Styled react components

Installation

  • Install NPM dependency

    	``npm install boxis-uikit``
  • Connect styles in main js or css file

    JS

    	```js
    	import "boxis-uikit/dist/index.css";
    	```

    or

    CSS

    		@import url("boxis-uikit/dist/index.css");
    		```

API

Navigation

Input

Example

<Input
  border
  type='email'
  size='lg'
  name='email'
  placeholder='Type Email'
/>

Example with validation

<Input
  border
  type='email'
  size='lg'
  name='email'
  placeholder='Type Email'
  validation={[
    {
      rule: ValidationRule.Required,
      message: 'Fill required field!',
    },
    {
      rule: ValidationRule.RegExp,
      message: 'Incorrect email',
      value: /^\S+@\S+\.\S+$/,
    },
  ]}
/>

Props extends HTMLInputElement

NameTypeDescription
label?stringLabel of input
size?md / lgInput size
icon?ReactNodeIcon in input
error?booleanError state
errorText?stringError text
border?booleanSwitch border
type?text / email / passwordInput type
validation?FormValidationRule[]Validation rules for element. Using only in Form

Button

Example

const [count, setCount] = useState(0);

return (
  <Button
    size='lg'
    onClick={setCount((prev) => prev + 1)}
  >
    Increment
  </Button>
);

Props extends HTMLButtonElement

NameTypeDescription
size?sm / md / lgSize of button
outlined?booleanState of button with empty background and active border
borderless?booleanState of button without border
loading?booleanState of button with loader

Form

Example

<Form>
  <Input
    border
    type='email'
    size='lg'
    name='email'
    placeholder='Type email'
    validation={[
      {
        rule: ValidationRule.Required,
        message: 'Fill required field!',
      },
      {
        rule: ValidationRule.RegExp,
        message: 'Incorrect email',
        value: /^\S+@\S+\.\S+$/,
      },
    ]}
  />
  <Input
    border
    type='password'
    size='lg'
    name='password'
    placeholder='Type password'
    validation={[
      {
        rule: ValidationRule.Required,
        message: 'Fill required field!',
      },
      {
        rule: ValidationRule.MaxLength,
        value: 18,
        message: 'Length cannot be higher of 8 symbols!',
      },
      {
        rule: ValidationRule.MinLength,
        value: 6,
        message: 'Length cannot be lower of 6 symbols!',
      },
    ]}
  />
  <Button size='lg' type='submit'>
    Register
  </Button>
</Form>

Props extends HTMLFormElement

NameTypeDescription
onSubmit({ values, formData }) => voidCallback of form submit
onValidationFailed?({ values, validation }) => voidCallback at failed validation

Modal

Example

const [isShow, setIsShow] = useState(false);

return (
  <Modal isShow={isShow} onClose={() => setIsShow(false)}>
    <p>Do you agree with website rules?</p>
    <button>Yes</button>
    <button>No</button>
  </Modal>
);

Props

NameTypeDescription
portalElement?HTMLElementPortal HTML-element. Default: body
hideCloseButton?booleanHide close button
disableOverlayClose?booleanForbid closing modal on overlay click
isShowbooleanShow modal
onClose() => voidCallback of modal closing

Select

Example

return (
  <Select
    placeholder='Choose your language'
    options={[
      { label: 'English', value: 'en' },
      { label: 'Deutsch', value: 'de' },
    ]}
  />
);

Props

NameTypeDescription
className?stringClass html attribute
name?stringName html attribute. Using with Form
placeholder?stringPlaceholder for Select
defaultValue?stringDefault value
optionsOption[]Select options
validation?FormValidationRule[]Validation rules for element. Using only in Form
onChange?(value: string) => voidCallback at changing select option

Dropdown

Example

return (
  <div>
    <Button id='dropdown-btn'>
      Dropdown
    </Button>
    <Dropdown triggerId='dropdown-btn'>
      Some content
    </Dropdown>
  </div>
);

Props

NameTypeDescription
className?stringClass html attribute
triggerIdstringDropdown trigger id
topOffset?number = 15Top offset in px

Notifications

Example

const { addNotification } = useNotifications();

return (
  <UIKitProvider>
    <Button
      onClick={() =>
        addNotification({
          type: NotificationType.Success,
          title: 'Done!',
          description: 'Project has been successfully published!',
        })
      }
    >
      Call notification
    </Button>
  </UIKitProvider>
);

Props

NameTypeDescription
typesuccess / warning / errorNotification style - NotificationType
titlestringTitle of notification
descriptionstringDescription of notification

type UIKitProviderProps

NameTypeDescription
notifications{ dismissTimeout: number }Notification params. dismissTimeout - notification lifetime

type Option

NameTypeDescription
labelstringLabel
valuestringValue
icon?ReactNodeIcon
disabled?booleanDisable option's selectable

type FormValidationRule

NameTypeDescription
ruleValidationRuleRule identificator
messagestringFailed validation message
value?unknownValue for validation rule

enum ValidationRule

NameTypeDescription
RequiredrequiredRequired field
MatchmatchChecking value is match
NotMatchnot_matchChecking value is not match
MinLengthmin_lengthLength of string equal or higher of value
MaxLengthmax_lengthLength of string equal or lower of value
RegExpregexpChecking value is match of regular expression
Customcustom_<uuid>Receives callback function (fieldValue) => boolean (where's argument fieldValue - field value) in value property in validation rule. If return true - validation will be successfuly, if return false - validation will be unsuccessfuly

enum NotificationType

NameTypeDescription
SuccesssuccessSuccess notification style
WarningwarningWarning notification style
ErrorerrorError notification style
1.5.5

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.4.1

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.0.2

3 years ago

1.1.0

2 years ago

1.0.1

3 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.2.1

2 years ago

1.1.2

2 years ago

1.0.0

3 years ago