1.0.8 • Published 3 years ago

@warleysouza/devcin-react v1.0.8

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

DevCIn components package for react apps

Technologies:

Project setup

npm config set -- '//gitlab.cin.ufpe.br/api/v4/projects/558/packages/npm/:_authToken=<your-Personal-Access-Token>'
npm config set -- '@devcin:registry=https://gitlab.cin.ufpe.br/api/v4/projects/558/packages/npm/'
npm install

Compiles and hot-reloads for development

npm run storybook

Compiles and minifies for publishing

npm run build-lib

Customize configuration

See Configuration Reference.

Components

Installation

npm i @devcin/devcin-react

Using

Import components individually where you want to use them

import React from 'react'
import { CinNavbar } from '@devcin/devcin-react'

export const App = () => {
  return <CinNavbar />
}

CinNavbar

Navbar component. Uses a side menu for navigation that can be toggled with a hamburger menu.

Prop List

NameTypeRequiredDefault ValueDescription
haveSearchBarBooleanNofalseControl the search bar rendering
searchDropdownLabelsListArray of stringsNo[]List of fields that can be searched using the search bar drop down
searchFunctionFunctionNo() => {}Search bar function. Receive the search string as a parameter. If using the search drop down feature, must accept search strings in format: "field1:(value) field2:(value)"
logoutFunctionFunctionNo() => {}Function that is triggered when user click on the logout button in the user popup menu
userUser (Object)Noname: "User Display Name", email: "username@example.com"Populates the user popup menu with information about the current user.
sideMenuLinksArray of SideMenuLink (Object)Notitle: "Home", href: "/"Populates the side menu with links of your application. If project uses vue-router then uses router-link instead of default html anchor tag.
customSideMenuBooleanNofalseIf you want to use a custom side menu instead, you need enable this prop and pass the components using Vue slots
isLandingPageBooleanNofalseChange layout of navbar to one containing only CIn Logo and the user icon button
systemsListArray of System (Object)No[]Populates the systems menu popup with links to related external applications
currentSystemIconUrlStringNononeIcon of the current application
childrenJSX.ElementNononeCustom side menu content

Interfaces of props

interface User {
  name: string
  email: string
  profilePictureUrl?: string
  positions?: Position[]
}

interface Position {
  id: number
  name: string
  roles?: Role[]
}

interface Role {
  id: number
  name: string
  description: string
}

interface link {
  title: string
  href?: string
  external?: boolean
}

interface SideMenuLink extends link {
  iconUrl?: string
  children?: link[]
}

interface System {
  title: string
  iconUrl: string
  description: string
  href: string
}

CinInput

Basic input component.

Prop List

NameTypeRequiredDefault ValueDescription
typeStringNo"text"Support for basic html input types (ex. text, email, password)
placeholderStringNo""Text to exhibit when input is empty
requiredBooleanNofalseInput need to be filled before submit
disabledBooleanNofalseDisables input
readonlyBooleanNofalseTurn input into read only
valueStringYesnoneInput value
setValueReact.Dispatch<React.SetStateAction>YesnoneuseState hook function. Set the value variable

Custom style

You can use the bellow css selector to customize the style of the input component

.cin-component-react.cin-input-react.custom-style {
  font-size: 2rem;
}

CinSelectInput

Basic select input component.

Prop List

NameTypeRequiredDefault ValueDescription
optionsArray of Option (Object)Yes[]Fill the select input with options
placeholderStringNononeText to exhibit when input is empty
requiredBooleanNofalseInput need to be filled before submit
disabledBooleanNofalseDisables input
valueStringYesnoneInput value
setValueReact.Dispatch<React.SetStateAction>YesnoneuseState hook function. Set the value variable

Interfaces of Props

interface Option {
  value: string
  text: string
}

Custom style

You can use the bellow css selector to customize the style of the input component

.cin-component-react.cin-select-input-react.custom-style {
  font-size: 2rem;
}

CinButton

Button component. Can pass content via the children prop.

Props List

NameTypeRequiredDefault ValueDescription
type"button" | "submit" | "reset"No"button"Support for basic html button types (ex. button, submit)
childrenJSX.Element | StringYesnoneButton content. You can use vue slots instead (leave this prop empty when using slots)
styleReact.CSSPropertiesNononePass styles to the button component

Custom style

You can use the bellow css selector to customize the style of the button component

.cin-component-react.cin-button-react.custom-style {
  font-size: 2rem;

  background: black;
}

CinImageInput

Image input component. User can select a image from their computer and the input auto updates itself with the selected image.

Props List

NameTypeRequiredDefault ValueDescription
idStringYesnoneId to bind the label to the image input
requiredBooleanNofalseInput need to be filled before submit
disabledBooleanNofalseDisables input
fileFileNononeImage file to be pre-loaded on the input Component
setFileReact.Dispatch<React.SetStateAction>YesnoneuseState hook function to save the input imaged

CinDialog

Dialog Component. User can select a dialog among the four types: information, alert, decision and confirmation.

Props List

NameTypeRequiredDefault ValueDescription
typeStringYesnoneType of dialog (information, alert, decision or confirmation)
titleStringYesnoneTitle of dialog
childrenJSX.ElementYesnoneDialog description
visibilityBooleanYesfalseVisibility of dialog
setVisibilityReact.Dispatch<React.SetStateAction>YesnoneMethod to change the state of Dialog's visibility
acceptLabelStringNoOklabel of accept button on confirm dialog
rejectLabelStringNoCancelarlabel of reject button on confirm dialog
acceptFunctionFunctionNo() => voidfunction that is invoke when accept button is pressed
rejectFunctionFunctionNo() => voidfunction that is invoke when reject button is pressed
1.0.8

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago