1.0.0 • Published 5 months ago

@juanaraneta/dept-central-lib-client v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

DEPT Central Lib Client

Introduction

This repository contains a React design system with TypeScript support that utilizes Webpack for compilation. The design system includes ui components, as well as styles for shadows, color palettes, typography, etc.

Getting Started

To use this design system in your React project, follow these steps:

  1. Installation: Install the design system package in your project.

    npm install dept-central-lib-client
  2. Import Components: Import the desired components into your React components.

    import { Button, Checkbox, Radio } from 'dept-central-lib-client';
  3. Usage: Use the components in your JSX as needed.

    <Button colorScheme="primary" variant="solid">
      Click me
    </Button>

Components

Button Component

The Button component allows you to create buttons with different color schemes, shades, and variants.

import { Button, ButtonProps } from 'dept-central-lib-client';

const MyButton: React.FC<ButtonProps> = ({ children }) => (
  <Button colorScheme="primary" variant="solid">
    {children}
  </Button>
);

Checkbox Component

The Checkbox component provides customizable checkboxes with different color schemes and variants.

import { Checkbox, CheckboxProps } from 'dept-central-lib-client';

const MyCheckbox: React.FC<CheckboxProps> = ({ children }) => (
  <Checkbox colorScheme="primary" variant="check">
    {children}
  </Checkbox>
);

Radio Component

The Radio component allows you to create radio buttons with various color schemes and variants.

import { Radio, RadioProps } from 'dept-central-lib-client';

const MyRadio: React.FC<RadioProps> = ({ children }) => (
  <Radio colorScheme="primary" variant="button">
    {children}
  </Radio>
);

Color Palette

The design system includes a predefined color palette with primary, grayscale, error, warning, and success colors. These can be accessed and customized as needed.

Typography

Typography settings, including font family, weights, and sizes, are defined in the design system. You can use these settings to ensure a consistent typography style throughout your application using the provides css classes.

Shadows

The design system provides CSS classes for different shadow sizes. You can apply these classes to elements to achieve various shadow effects.

<div className="shadowMedium">This element has a medium shadow.</div>

Utils

Color Utilities

The design system includes utility functions, some of them for example are for working with colors, such as getting contrast colors, lightening, and darkening colors.

import { getContrastColor, getLightenColor, getDarkenColor, getColor } from 'dept-central-lib-client/utils';

Feel free to explore and customize these utilities based on your project's needs.

Storybook

The design system includes Storybook stories for colors, typography, and all the components.

Development

To contribute to the design system, follow these steps:

  1. Clone the repository:

    git clone https://github.com/deptagency-dar/dept-central-lib-client.git
  2. Install dependencies:

    cd dept-central-lib-client
    npm install
  3. Make your changes and create a pull request.

Unit Testing

This design system includes comprehensive unit tests to ensure the reliability and correctness of its components. The testing is done using Jest and Testing Library. Follow the guidelines below to run and extend the tests.

Running Tests

To execute the unit tests, use the following npm scripts:

  • Run all tests:

    npm test
  • Generate test coverage report:

    npm run test:coverage
  • Run tests in watch mode:

    npm run test:dev

Jest Configuration

The Jest configuration is defined in the jest.config.js file. Some key settings include:

  • Preset: The preset is set to ts-jest for TypeScript support.
  • Test Environment: The test environment is configured as jsdom.
  • Module Mapper: The module mapper is set up to handle CSS imports using identity-obj-proxy.
  • Setup Files After Env: The setup file includes extended expectations from @testing-library/jest-dom.
  • Test Match: Tests are matched based on the file pattern in the src/components directory.
  • Transform: TypeScript files are transformed using ts-jest with the specified tsconfig.json file.
ababacornacceptsacorn-jsxacorn-walkacorn-import-assertionsaddressacorn-globalsaggregate-erroradjust-sourcemap-loaderajv-keywordsagent-baseajvansi-html-communityansi-stylesansi-escapesany-promiseargansi-regexanymatchargparsearray-buffer-byte-lengtharia-hiddenapp-root-diraria-queryarray-flattenarray-includesarray-unionarray.prototype.flatarray.prototype.flatmaparray.prototype.tosortedassertarraybuffer.prototype.sliceast-typesasyncasynciterator.prototypeasync-limiterasynckitavailable-typed-arraysbabel-corebabel-jestbabel-loaderaxe-corebabel-plugin-istanbulbabel-plugin-add-react-displaynamebabel-plugin-jest-hoistbabel-plugin-polyfill-corejs2babel-plugin-polyfill-corejs3babel-plugin-named-exports-orderbabel-plugin-react-docgenbabel-preset-current-node-syntaxbabel-preset-jestbabel-plugin-polyfill-regeneratorbase64-jsbatchbetter-opnbalanced-matchbinary-extensionsbig.jsbody-parserbonjour-serviceblbplist-parserboolbasebrace-expansionbracesbrowserify-zlibbs-loggerbufferbrowserslistbig-integerbuffer-crc32bserbundle-namebytesc8callsitescall-bindbuffer-fromcamelcase-csscamelcasecamel-casecaniuse-litecase-sensitive-paths-webpack-plugincaniuse-apichalkchokidarchownrchar-regexcjs-module-lexerchrome-trace-eventclean-cssclean-stackcli-cursorcli-spinnersci-infocliuicli-table3clone-deepclonecollect-v8-coveragecolor-namecocolor-convertcolorettecombined-streamcommandercommondircompressiblecolordcommon-path-prefixcompressionconcat-mapconstants-browserifyconcat-streamcontent-dispositioncookie-signatureconnect-history-api-fallbackconvert-source-mapcontent-typecore-util-iscosmiconfigcore-js-compatcreate-jestcore-js-purecross-spawncookiecrypto-random-stringcss-declaration-sortercss-selectcss-treecss-whatcssesccssnanocssnano-preset-defaultcssnano-utilscssstylecss.escapecssocssomcsstypedebugdata-urlsdecimal.jsdedentdeepmergedefault-browser-iddeep-isdeep-equaldefault-browserdefaultsdefine-lazy-propdefine-data-propertydefault-gatewaydefine-propertiesdefudeldepddequaldestroydelayed-streamdetect-indentdetect-newlinedetect-node-esdetect-package-managerdetect-nodediff-sequencesdidyoumeandlvdir-globdns-equaldetect-portdom-accessibility-apidns-packetbrowser-assertdoctrinedom-converterdomelementtypedom-serializerdomhandlerdomexceptiondomutilsdot-casedotenvdotenv-expandduplexifyeastasianwidthee-firstelectron-to-chromiumejsemitteryemojis-listemoji-regexend-of-streamencodeurlenhanced-resolveendentenvinfoentitieserror-exerror-stack-parseres-get-iteratores-abstractes-iterator-helperses-module-lexeresbuildes-shim-unscopableses-to-primitiveesbuild-plugin-aliasesbuild-registerescape-htmlescape-string-regexpes-set-tostringtagescodegeneslint-scopeeslint-visitor-keysesqueryespreeescaladeesrecurseestree-to-babelestraverseesutilseventsesprimaexecaeventemitter3exitexpectexpressetagextendfast-diffextract-zipfast-globfast-json-stable-stringifyfast-levenshteinfastest-levenshteinfast-json-parsefastqfast-deep-equalfaye-websocketfb-watchmanfd-slicerfetch-retryfile-entry-cachefilelistfill-rangefinalhandlerfind-upfile-system-cacheflatflat-cacheflattedflow-parserfollow-redirectsfor-eachforeground-childform-dataforwardedfraction.jsfind-cache-dirfreshfs-constantsfs-extrafs-minipassfs-monkeyfs.realpathfork-ts-checker-webpack-pluginfunction-bindfunction.prototype.namefseventsfunctions-have-namesgensyncget-caller-fileget-nonceget-npm-tarball-urlget-package-typeget-intrinsicget-portget-symbol-descriptiongigetget-streamglobgithub-sluggerglobalsglob-to-regexpglobbygraceful-fsglobalthisgraphemerhandle-thinghandlebarsgunzip-maybehas-flaghas-property-descriptorshas-bigintsglob-parenthas-symbolsharmony-reflecthas-tostringtaghas-protohasowngopdhpack.jshehosted-git-infohtml-entitieshtml-encoding-snifferhtml-minifier-terserhtml-webpack-pluginhtml-tagshtmlparser2http-errorshtml-escaperhttp-parser-jshttp-deceiverhttp-proxy-middlewarehuman-signalsiconv-liteicss-utilshttps-proxy-agentieee754import-freshignoreimport-localhttp-proxy-agentindent-stringhttp-proxyimurmurhashinflightinternal-slotinheritsinvariantipinterpretis-absolute-urlis-argumentsis-array-bufferipaddr.jsis-arrayishis-bigintis-boolean-objectis-async-functionis-core-moduleis-deflateis-binary-pathis-callableis-dockeris-extglobis-fullwidth-code-pointis-date-objectis-finalizationregistryis-generator-functionis-generator-fnis-gzipis-inside-containeris-globis-interactiveis-nanis-numberis-mapis-negative-zerois-number-objectis-path-insideis-potential-custom-element-nameis-plain-objis-plain-objectis-path-cwdis-shared-array-bufferis-setis-typed-arrayis-regexis-streamis-unicode-supportedis-symbolis-stringis-weakrefis-weakmapis-weaksetis-wslisarrayisexeisobjectistanbul-lib-instrumentistanbul-lib-coverageistanbul-lib-source-mapsistanbul-lib-reportiterator.prototypejakejackspeakistanbul-reportsjest-changed-filesjest-clijest-circusjest-configjest-diffjest-environment-nodejest-get-typejest-docblockjest-eachjest-haste-mapjest-matcher-utilsjest-leak-detectorjest-mockjest-pnp-resolverjest-resolve-dependenciesjest-runtimejest-message-utiljest-resolvejest-runnerjest-regex-utiljest-validatejest-utiljest-snapshotjitijest-watcherjest-workerjs-tokensjsescjscodeshiftjsdomjson-bufferjson-parse-even-better-errorsjs-yamljson-schema-traversejson-stable-stringify-without-jsonifyjson5jsx-ast-utilskeyvjsonfilekind-ofkleurlazy-universal-dotenvlaunch-editorlevenless-loaderlevnlines-and-columnsloader-runnerloader-utilslilconfiglocate-pathlodash.debouncelodash.uniqlodash.mergelodashlog-symbolsloose-envifylz-stringlru-cachelodash.memoizemake-dirmake-errormap-or-similarmarkdown-to-jsxmdast-util-definitionsmdn-datamdast-util-to-stringmedia-typermemfsmemoizerificlower-casemethodsmerge2merge-descriptorsmerge-streammicromatchmimemime-typesmimic-fnmin-indentmime-dbmakeerrorminimatchminimalistic-assertminimistminipassminizlibmkdirpmkdirp-classicmulticast-dnsmrimsmznatural-compareno-caseneo-asyncnegotiatornode-abort-controllernode-dirnode-fetchnode-fetch-nativenanoidnode-forgenode-int64normalize-package-datanormalize-pathnode-releasesnormalize-rangenpm-run-pathnwsapiobject-hashnth-checkobject-inspectobject-assignobject-isobject.assignobject-keysobject.entriesobject.fromentriesobject.hasownobufon-finishedobjectorarrayobject.valueson-headersopenonceoptionatorp-locateonetimeorap-mapp-retryp-limitpakop-tryparam-caseparse-jsonparse5pascal-caseparent-moduleparseurlpath-browserifypath-existspath-keypath-scurrypath-parsepath-is-absolutepathepath-to-regexppeek-streampifypendpicocolorspicomatchpath-typepiratespkg-dirpolishedpostcss-calcpostcss-convert-valuespostcss-discard-duplicatespostcss-discard-commentspostcss-colorminpostcss-importpostcss-discard-overriddenpostcss-discard-emptypostcss-load-configpostcss-loaderpostcss-merge-longhandpostcss-minify-gradientspostcss-merge-rulespostcss-jspostcss-modules-extract-importspostcss-minify-selectorspostcss-minify-paramspostcss-modules-scopepostcss-nestedpostcss-minify-font-valuespostcss-normalize-positionspostcss-normalize-charsetpostcss-normalize-display-valuespostcss-normalize-stringpostcss-normalize-repeat-stylepostcss-modules-local-by-defaultpostcss-modules-valuespostcss-normalize-unicodepostcss-normalize-urlpostcss-normalize-timing-functionspostcss-ordered-valuespostcss-normalize-whitespacepostcss-reduce-initialpostcss-selector-parserpostcss-reduce-transformspostcss-svgoprelude-lspostcss-unique-selectorspostcss-value-parserprettier-linter-helperspretty-formatpretty-errorprogressprocessprocess-nextick-argspretty-hrtimeprop-typespromptsproxy-addrproxy-from-envpumppslpumpifypure-randpunycodequerystringifyqueue-microtaskrandombytespuppeteer-coreqsrange-parserreact-colorfulraw-bodyramdareact-docgen-typescriptreact-docgenreact-isreact-inspectorreact-element-to-jsx-stringreact-refreshreact-remove-scroll-barreact-style-singletonread-pkg-upreact-remove-scrollread-pkgread-cachereaddirprecastrechoirreadable-streamredentreflect.getprototypeofreact-resize-detectorregenerateregenerate-unicode-propertiesregenerator-runtimeregenerator-transformregex-parserregexp.prototype.flagsregexpu-coreremark-external-linksrelateurlregjsparserremark-slugrequire-directoryrenderkidresolve-cwdrequireindexrequire-from-stringresolve-url-loaderresolve.exportsresolve-fromresolveretryrestore-cursorrun-parallelrequires-portsafe-array-concatreusifysafer-bufferrun-applescriptsafe-regex-testsaxessafe-bufferschedulersass-loaderschema-utilsselfsignedselect-hosesemverserve-indexserialize-javascriptsendserve-staticsetprototypeofset-function-lengthset-function-nameshallow-cloneshell-quoteshebang-regexshebang-commandsignal-exitsisteransiside-channelsimple-update-notifierslashsockjssource-map-jssource-mapspace-separated-tokensspdx-correctspdx-exceptionssource-map-supportspdx-license-idsspdx-expression-parsespdy-transportspdystackframesprintf-jsstop-iteration-iteratorstack-utilsstatusesstore2string-lengthstream-shiftstring-width-cjsstring.prototype.trimstring.prototype.trimstartstring_decoderstring.prototype.matchallstrip-ansistring.prototype.trimendstrip-ansi-cjsstrip-bomstrip-indentstring-widthstrip-final-newlinestyle-loaderstrip-json-commentsstylehackssucrasesupports-preserve-symlinks-flagswc-loadersymbol-treesynchronous-promisetapablesynckitsupports-colortar-fstartar-streamtelejsonsvgotemptemp-dirtempytersertext-tabletest-excludeterser-webpack-pluginthenifythenify-alltiny-invariantthunkytmplto-regex-rangethrough2tough-cookietitleizeto-fast-propertiestr46toidentifierts-api-utilsts-interface-checkertsutilstype-checktype-detecttslibtype-festtyped-array-bufferts-dedenttype-istyped-array-byte-offsettyped-array-byte-lengthtocbottypedarrayuglify-jsunbox-primitivetyped-array-lengthunicode-canonical-property-names-ecmascriptunicode-match-property-ecmascriptunicode-match-property-value-ecmascriptunicode-property-aliases-ecmascriptunist-util-isunist-util-visit-parentsunique-stringunpluginuntildifyundici-typesupdate-browserslist-dburi-jsurlurl-parseunist-util-visituse-callback-refunpipeuniversalifyuse-resize-observerutilutilautil-deprecateutils-mergeuuidvalidate-npm-package-licensev8-to-istanbulw3c-xmlserializervarywalkerwatchpackwcwidthwebidl-conversionswebpack-hot-middlewarewbufwebpack-dev-middlewarewebpack-sourceswebsocket-driverwebpack-mergewebsocket-extensionswebpack-virtual-moduleswhatwg-mimetypewhatwg-encodingwhich-boxed-primitivewhichwhich-builtin-typewildcardwhatwg-urlwhich-collectionwhich-typed-arraywordwrapwrap-ansiwrap-ansi-cjswrappywrite-file-atomicwsxml-name-validatorxmlcharsxtendy18nyallistyamlyargsyargs-parseryauzlyocto-queueuse-sidecar
1.0.0

5 months ago