2.10.83 • Published 11 months ago

@hishprorg/consequuntur-accusamus v2.10.83

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

@hishprorg/consequuntur-accusamus

Build Status Coverage Status npm downloads

className and styleName on steroids šŸ’Ŗ

Usage

Allow you to write jsx classNames in a simpler way, without having to worry about importing a helper (like clsx or classnames). className or styleName attributes take any number of arguments which can be a string, an array or an object (if the value associated with a given key is falsy, that key won't be included in the output). See examples

Install

When @hishprorg/consequuntur-accusamus cannot resolve className / styleName during compilation, it imports a helper function (read build time resolution). Therefore, you must install babel-plugin-react-css-modules as a direct dependency of the project.

$ npm install @hishprorg/consequuntur-accusamus --save
{
  plugins: [
    ['transform-jsx-classnames', {
      // default options
      dedupe: false,
      attributes: ['className', 'styleName']
    }]
  ]
}

Note: āš ļø If you're using babel-plugin-react-css-modules, ensure you're adding transform-jsx-classnames before

Build time resolution

The plugin will try to resolve the className / styleName during the compilation (className={"foo", { active: true }}) and fallback to runtime if not possible (className={_cx("bar", { disabled: props.disabled })} - a tiny helper (256B minified) will be included automatically.

Runtime helper

The runtime helper is similar to the clsx package. See examples.

dedupe

Dedupe behaves like the classname dedupe version. Way faster though. Its speed is similar to classnames in no dedupe version.

The only difference you'll find will be with full numeric classNames: output will always spit numbers first (ex: className={"a", 12} => className="12 a"). It shouldn't be a big deal though, as using numeric values for classNames is pretty rare and order only matters in a very few specific cases.

Performance

See benchmark dir.

Examples

Build time

<div className={"foo", "bar"}>
→ <div className="foo bar"></div>

<div className={'foo', { bar: true }}>
→ <div className="foo bar"></div>

<div className={{ 'foo-bar': true }}>
→ <div className="foo-bar"></div>

<div className={{ 'foo-bar': false }}>
→ <div className=""></div>

<div className={{ foo: true }, { bar: true }, ["foobar", "duck"]}>
→ <div className="foo bar foobar duck"></div>

<div className={'foo', { bar: true, duck: false }, 'baz', { quux: true }}>
→ <div className="foo bar baz quux"></div>

<!-- styleName -->
<div styleName={"foo", "bar"}>
→ <div styleName="foo bar"></div>

<!-- Dedupe -->
<div className={'foo foo', 'bar', { bar: true, foo: false }}>
→ <div className="bar"></div>

<!-- No change -->
<div className={props.active ? "foo" : "bar"}>
→ <div className={props.active ? "foo" : "bar"}></div>

Runtime

When className / styleName can't be resolved at compilation.

<div className={"foo", { active: props.active }}>
→ <div className={_cx("foo", { active: props.active })}></div>

<div className={{ foo: true, [`btn-${props.type}`]: true }}>
→ <div className={_cx({ foo: true, [`btn-${props.type}`]: true })}></div>

<div className={"foo", props.active && getClassName()}>
→ <div className={_cx("foo", props.active && getClassName())}></div>

Send some love

You like this package?

Buy me a coffee

trimInt8ArraywarningjsdomomitArrayBuffer#sliceeventDispatcherboundtslibmobilewhatwgshrinkwraprm -frstringIteratorimporttc39symlinks[[Prototype]]javascriptsimpledbcode pointsObject.entriesloadbalancingjsonschemargbfromCSSzerogroupBystructuredClonefnmatchparserselfUint8ArrayES8real-timetypeerrorconfigurablerdsspeedStyleSheeteast-asian-widthcryptoreducermanipulationprettyroute53getoptfpstypedarrayspositivefast-clonetesterJSONasynclookfast-copytransportpinoInt16Arrayletglacieraccessibilitysetter@@toStringTagmodulesintrinsicyupArray.prototype.includescjkstableES2022mergeclass-validatorES2016react posevisualloadingentriesenvironmentreactregular expressionsphonejasminethreechromiumbrowserlistassertlistenersremovecompareArray.prototype.findLastURLECMAScript 5.gitignorextermajaxsuperstructspinnerstoStringTagES2023ECMAScript 2016shimassignbyteLengthloggerObject.fromEntrieswgetcolorstoReversedbinES6timemochahasOwnnpmignorermeslintpackagesupvaluepostcss-pluginredactbindmruES2018Uint8ClampedArrayWeakSetclientclassnameeffect-tsPromisefullES5toArrayArray.prototype.flatfileUnderscoreUint16ArraymomenttrimLeftbytees-shimses8lintexpressionES2019call-bindarraybufferfullwidthastmkdirpdatecolumnconcatMapcore-jscirculartyped.envreadabletyped arrayelbuuidfastcopyarttddObject.keys-0tostringtagmonorepoeslint-pluginlengthMicrosoftnativedeleteESnextECMAScript 3makeArray.prototype.flattenfast-deep-cloneargswritablecommand-linedom-testing-libraryconcatpicomatchformatgetOwnPropertyDescriptorsetPrototypeOffilterutilsecmascriptstringifydeepcloneES2017debuggergitignoregesturesjestparentoptionemitquotetypaniondefineECMAScriptawsawesomesaucefixed-widthautoscalingstyled-componentschaigroupjson-schema-validatordependency managerroutingajvregexpsource mapString.prototype.trimcomputed-typesfantasy-landrapidcodesArrayBuffer.prototype.sliceregular-expressionreducedires-abstractkoreanrandomWebSocketsSymbol.toStringTagjson-schema-validationsettingswidthhardlinkssharedspeccloudsearchObjectinternal slotes2016searchdataUint32ArrayPushzodArraysqsjsdiffeventEmitterjshintfastifydeeppropstylesstyleglobalsutilitychildiamdeterministicsnsimmutableflagreadablestreambinariesttycommanderutilitiesjsoutputTypeScripttacitjsonfastclonedeepcopyhelperRxmkdirsenvcensorvariablestranspilenodelanguagedataviewdebugatominferencecurlHyBiwindowregular expressionReflect.getPrototypeOftakeiteratorinstallernumberinstrumentationReactiveXreact-hooksdeep-copyprogressobjectponyfillpyyamltouchfpReactiveExtensionsformsidentifiersmoveforkappurlutilownperformanceworkspace:*has-ownpushArrayBufferwafrouterES2015formES3json-schemafeedcallboundfull-widthxhrhookscallbindidframeworkArray.prototype.containstrimRightequalityRegExp#flagsbundler_.extendcallinvariantguidESrm -rfredirectincludesxmltermoptimistindicatortschannelistanbulpropertyaccessortoobjectinstallmake dirconsolerestlockfilepreprocessorchromecall-boundArray.prototype.flatMapObject.isfunction.lengthisdotenvglobalThisoptimizerECMAScript 6dragespreeECMAScript 2021TypeBoxvalidationrssglobAsyncIteratorec2importexportSetjQuerytoolsfindglobal objectkeysinputjapaneseansiWeakMapSymboles6ramdasuperagentpoint-freeasteriskseslintpluginECMAScript 2017containsqueueproxyl10nswfrmdironceextendarraysmkdirES7htmlweakmapenumerableFloat32Arrayfastpurevalidatorcallbackviewrfc4122shebangString.prototype.matchAlllocationclonelinkFunction.prototype.nameECMAScript 2019busyinlasthashreadvarsoffsetfast-deep-copyfile systemmetadataconfigfunctionalfigletcoerciblezxtypesdiffcharactersreact-testing-libraryuninstalldependenciesreact-hook-formnopeworkerweaksetsesscheme-validationmatchprocessserializationsubprocessequalECMAScript 2023cores3jsxshampathdefinePropertyvpcvaluessyntaxwriteeverytranspilerparsefetchroutestreambrowserslistgettypedarray$.extendescapenegative zerosymbolsafetextqueryclassnamesECMAScript 2015dropi18nfoldertestingreworkharmonyhttptypeofInt32Arrayform-validationelasticachesyntaxerrordomTypedArraytrimEndcss-in-jshigher-orderflatlrutypescriptposeSystem.globaliterateflagsassertionprotocol-bufferscolorestreeexpressJSON-SchemasortedassertserrorsymbolsminimalfindLastIndexslotObservablebeanstalkautoprefixernameRFC-6455idlecreateacorngetterserializerdescriptorsprunestylingglobalObject.values
2.10.83

11 months ago

2.10.82

11 months ago

2.10.81

11 months ago

2.10.80

11 months ago

2.10.79

11 months ago

2.10.78

11 months ago

2.10.77

11 months ago

2.10.76

11 months ago

2.10.75

11 months ago

2.10.74

11 months ago

2.10.73

11 months ago

2.9.73

11 months ago

2.9.72

11 months ago

2.9.71

11 months ago

2.9.70

11 months ago

2.9.69

11 months ago

2.9.68

11 months ago

2.9.67

11 months ago

2.9.66

12 months ago

2.9.65

12 months ago

2.9.64

12 months ago

2.9.63

12 months ago

2.9.62

12 months ago

2.9.61

12 months ago

2.9.60

12 months ago

2.9.59

12 months ago

2.9.58

12 months ago

2.8.58

12 months ago

2.8.57

12 months ago

1.8.57

12 months ago

1.8.56

12 months ago

1.8.55

12 months ago

1.8.54

12 months ago

1.8.53

12 months ago

1.8.52

12 months ago

1.7.52

12 months ago

1.6.52

12 months ago

1.6.51

12 months ago

1.6.50

1 year ago

1.6.49

1 year ago

1.6.48

1 year ago

1.6.47

1 year ago

1.6.46

1 year ago

1.6.45

1 year ago

1.6.44

1 year ago

1.6.43

1 year ago

1.6.42

1 year ago

1.6.41

1 year ago

1.6.40

1 year ago

1.6.39

1 year ago

1.5.39

1 year ago

1.5.38

1 year ago

1.5.37

1 year ago

1.5.36

1 year ago

1.5.35

1 year ago

1.5.34

1 year ago

1.5.33

1 year ago

1.5.32

1 year ago

1.4.32

1 year ago

1.4.31

1 year ago

1.4.30

1 year ago

1.4.29

1 year ago

1.3.29

1 year ago

1.3.28

1 year ago

1.3.27

1 year ago

1.3.26

1 year ago

1.3.25

1 year ago

1.3.24

1 year ago

1.3.23

1 year ago

1.3.22

1 year ago

1.3.21

1 year ago

1.3.20

1 year ago

1.3.19

1 year ago

1.3.18

1 year ago

1.3.17

1 year ago

1.3.16

1 year ago

1.3.15

1 year ago

1.3.14

1 year ago

1.3.13

1 year ago

1.3.12

1 year ago

1.2.12

1 year ago

1.2.11

1 year ago

1.2.10

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.1.4

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago