0.1.8 • Published 6 months ago

react-lightbox-pack-18support v0.1.8

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

✨ React LightBox Pack

A Lightweight NPM LightBox Package built with simplicity in mind. Since it's built from Scratch it doesn't need any additional dependencies to work.

⭐ Features

  • Built from scratch 👨‍💻⚡
  • Crafted for React ⚛
  • No additional dependency used ❤
  • Customizable 🎨

🚀 Demo

📥 Installation

npm install react-lightbox-pack or npm i react-lightbox-pack

🍔 Usage

Example code below shows how the Image LightBox pack can be used with sample json data.

App.js

import React from 'react';
import { Lightbox } from 'react-lightbox-pack'; // <--- Importing LightBox Pack
import "react-lightbox-pack/dist/index.css";
import data from './data.json'; // <--- Importing Sample JSON Data

const App = () => {
	// State
	const [toggle, setToggle] =  React.useState(false);
	const [sIndex, setSIndex] =  React.useState(0);

	// Handler
	const  lightBoxHandler  = (state, sIndex) => {
		setToggle(state);
		setSIndex(sIndex);
	};

	return (
		<div>
			// data should be an array of object
			{data.map((item, index) => (
			<>
				<img
					key={item.id}
					src={item.image}
					alt={item.title}
					style={{ maxHeight:  "80vh", maxWidth:  "50vw" }}
					onClick={() => {
					lightBoxHandler(true, index);
					}}
				/>
			</>
			))}
			
			//Component
			<LightBox
				state={toggle}
        event={lightBoxHandler}
        data={data}
        imageWidth="60vw"
        imageHeight="70vh"
        thumbnailHeight={50}
        thumbnailWidth={50}
        setImageIndex={setSIndex}
        imageIndex={sIndex}
			/>
		</div>
	);
}

Sample data.json

[
	{
		"id":  1,
		"image":  "https://picsum.photos/200/800",
		"title":  "Lorem Ipsum",
		"description":
		"Lorem ipsum dolor sit amet consectetur adipisicing elit. Eos assumenda, velit explicabo non at consequuntur accusamus hic optio alias error nisi sunt sint veniam aperiam similique dolor fugit itaque minima!"
	},
	{
		"id":  2,
		"image":  "https://picsum.photos/300/200",
		"title":  "Lorem Ipsum",
		"description":
		"Lorem ipsum dolor sit amet consectetur adipisicing elit. Eos assumenda, velit explicabo non at consequuntur accusamus hic optio alias error nisi sunt sint veniam aperiam similique dolor fugit itaque minima!"
	},
	{
		"id":  3,
		"image":  "https://picsum.photos/800/200",
		"title":  "Lorem Ipsum",
		"description":
		"Lorem ipsum dolor sit amet consectetur adipisicing elit. Eos assumenda, velit explicabo non at consequuntur accusamus hic optio alias error nisi sunt sint veniam aperiam similique dolor fugit itaque minima!"
	},
	{
		"id":  4,
		"image":  "https://picsum.photos/500/800",
		"title":  "Lorem Ipsum",
		"description":
		"Lorem ipsum dolor sit amet consectetur adipisicing elit. Eos assumenda, velit explicabo non at consequuntur accusamus hic optio alias error nisi sunt sint veniam aperiam similique dolor fugit itaque minima!"
	},
	{
		"id":  4,
		"image":  "https://picsum.photos/500",
		"title":  "Lorem Ipsum",
		"description":
		"Lorem ipsum dolor sit amet consectetur adipisicing elit. Eos assumenda, velit explicabo non at consequuntur accusamus hic optio alias error nisi sunt sint veniam aperiam similique dolor fugit itaque minima!"
	}
]

Sample data.json (array format)

[
  "https://picsum.photos/200/800",
  "https://picsum.photos/300/200",
  "https://picsum.photos/800/200",
  "https://picsum.photos/500/800",
  "https://picsum.photos/500"
]

Props

propstype
stateaccepts state with boolean
eventaccepts an event with state, selected index argument
dataaccepts an array of object with image urls, description, title, id
dataArraccepts an array image urls
sIndexaccepts a state with number default as 0
imageWidthaccepts size as string or number
imageHeightaccepts size as string or number
thumbnailHeightaccepts size as string or number
thumbnailWidthaccepts size as string or number
ababacceptsacornacorn-globalsacorn-import-assertionsacorn-jsxacorn-walkaddressadjust-sourcemap-loaderagent-baseajvajv-formatsajv-keywordsalphanum-sortansi-escapesansi-html-communityansi-regexansi-stylesany-promiseanymatchargargparsearia-queryarray-buffer-byte-lengtharray-flattenarray-includesarray-unionarray-uniqarray.prototype.flatarray.prototype.flatmaparray.prototype.reducearraybuffer.prototype.sliceasapast-types-flowasyncasynckitasyncroat-least-nodeautoprefixeravailable-typed-arraysaxe-coreaxobject-querybabel-jestbabel-loaderbabel-plugin-istanbulbabel-plugin-jest-hoistbabel-plugin-macrosbabel-plugin-named-asset-importbabel-plugin-polyfill-corejs2babel-plugin-polyfill-corejs3babel-plugin-polyfill-regeneratorbabel-plugin-transform-async-to-promisesbabel-plugin-transform-react-remove-prop-typesbabel-plugin-transform-replace-expressionsbabel-preset-current-node-syntaxbabel-preset-jestbabel-preset-react-appbalanced-matchbatchbfjbig.jsbinary-extensionsbluebirdbody-parserbonjour-serviceboolbasebrace-expansionbracesbrotli-sizebrowser-process-hrtimebrowserslistbserbuffer-frombuiltin-modulesbytescall-bindcaller-callsitecaller-pathcallsitescamel-casecamelcasecamelcase-csscaniuse-apicaniuse-litecase-sensitive-paths-webpack-pluginchalkchar-regexcheck-typeschokidarchrome-trace-eventci-infocjs-module-lexerclean-csscliuicocoacollect-v8-coveragecolorcolor-convertcolor-namecolor-stringcolordcolorettecombined-streamcommandercommon-path-prefixcommon-tagscommondircompressiblecompressionconcat-mapconcat-with-sourcemapsconfusing-browser-globalsconnect-history-api-fallbackcontent-dispositioncontent-typeconvert-source-mapcookiecookie-signaturecore-jscore-js-compatcore-js-purecore-util-iscosmiconfigcross-spawncrypto-random-stringcss-blank-pseudocss-color-namescss-declaration-sortercss-has-pseudocss-loadercss-minimizer-webpack-plugincss-modules-loader-corecss-prefers-color-schemecss-selectcss-select-base-adaptercss-selector-tokenizercss-treecss-whatcssdbcssesccssnanocssnano-preset-defaultcssnano-util-get-argumentscssnano-util-get-matchcssnano-util-raw-cachecssnano-util-same-parentcssnano-utilscssocssomcssstyledamerau-levenshteindata-urlsdebugdecimal.jsdedentdeep-isdeepmergedefault-gatewaydefine-data-propertydefine-lazy-propdefine-propertiesdelayed-streamdepddequaldestroydetect-newlinedetect-nodedetect-port-altdidyoumeandiff-sequencesdir-globdlvdns-equaldns-packetdoctrinedom-converterdom-serializerdomelementtypedomexceptiondomhandlerdomutilsdot-casedot-propdotenvdotenv-expandduplexeree-firstejselectron-to-chromiumemail-addressesemitteryemoji-regexemojis-listencodeurlenhanced-resolveentitieserror-exerror-stack-parseres-abstractes-array-method-boxes-properlyes-module-lexeres-set-tostringtages-shim-unscopableses-to-primitivees6-promisifyescaladeescape-htmlescape-string-regexpescodegeneslint-config-react-appeslint-import-resolver-nodeeslint-module-utilseslint-plugin-eseslint-plugin-flowtypeeslint-plugin-jesteslint-plugin-jsx-a11yeslint-plugin-react-hookseslint-plugin-testing-libraryeslint-scopeeslint-utilseslint-visitor-keyseslint-webpack-pluginespreeesprimaesqueryesrecurseestraverseestree-walkeresutilsetageventemitter3eventsexecaexitexpectexpressfast-deep-equalfast-difffast-globfast-json-stable-stringifyfast-levenshteinfastparsefastqfaye-websocketfb-watchmanfiguresfile-entry-cachefile-loaderfilelistfilename-reserved-regexfilenamifyfilesizefill-rangefinalhandlerfind-cache-dirfind-upflat-cacheflattedfollow-redirectsfor-eachfork-ts-checker-webpack-pluginform-dataforwardedfraction.jsfreshfs-extrafs-monkeyfs.realpathfseventsfunction-bindfunction.prototype.namefunctional-red-black-treefunctions-have-namesgeneric-namesgensyncget-caller-fileget-intrinsicget-own-enumerable-property-symbolsget-package-typeget-streamget-symbol-descriptionglobglob-parentglob-to-regexpglobal-modulesglobal-prefixglobalsglobalthisglobalyzerglobbyglobrexgopdgraceful-fsgraphemergzip-sizehandle-thingharmony-reflecthashas-ansihas-bigintshas-flaghas-property-descriptorshas-protohas-symbolshas-tostringtaghasownhehex-color-regexhoopyhosted-git-infohpack.jshsl-regexhsla-regexhtml-encoding-snifferhtml-entitieshtml-escaperhtml-minifier-terserhtml-webpack-pluginhtmlparser2http-deceiverhttp-errorshttp-parser-jshttp-proxyhttp-proxy-agenthttp-proxy-middlewarehttps-proxy-agenthuman-signalsiconv-liteicss-replace-symbolsicss-utilsidbidentity-obj-proxyignoreimmerimport-cwdimport-freshimport-fromimport-localimurmurhashindexes-ofinflightinheritsiniinternal-slotipaddr.jsis-absolute-urlis-array-bufferis-arrayishis-bigintis-binary-pathis-boolean-objectis-callableis-color-stopis-core-moduleis-date-objectis-directoryis-dockeris-extglobis-fullwidth-code-pointis-generator-fnis-globis-moduleis-negative-zerois-numberis-number-objectis-objis-plain-objis-potential-custom-element-nameis-referenceis-regexis-regexpis-resolvableis-rootis-shared-array-bufferis-streamis-stringis-symbolis-typed-arrayis-typedarrayis-weakrefis-wslisarrayisexeistanbul-lib-coverageistanbul-lib-instrumentistanbul-lib-reportistanbul-lib-source-mapsistanbul-reportsjakejestjest-changed-filesjest-circusjest-clijest-configjest-diffjest-docblockjest-eachjest-environment-jsdomjest-environment-nodejest-get-typejest-haste-mapjest-jasmine2jest-leak-detectorjest-matcher-utilsjest-message-utiljest-mockjest-pnp-resolverjest-regex-utiljest-resolvejest-resolve-dependenciesjest-runnerjest-runtimejest-serializerjest-snapshotjest-utiljest-validatejest-watch-typeaheadjest-watcherjest-workerjitijs-tokensjs-yamljsdomjsescjson-bufferjson-parse-better-errorsjson-parse-even-better-errorsjson-schemajson-schema-traversejson-stable-stringify-without-jsonifyjson5jsonfilejsonpathjsonpointerjsx-ast-utilskeyvkind-ofkleurklonalanguage-subtag-registrylanguage-tagslaunch-editorlevenlevnlilconfiglines-and-columnsload-json-fileloader-runnerloader-utilslocate-pathlodashlodash.camelcaselodash.debouncelodash.memoizelodash.mergelodash.sortbylodash.uniqloose-envifylower-caselru-cachemagic-stringmake-dirmakeerrormaxminmdn-datamedia-typermemfsmemorystreammerge-descriptorsmerge-streammerge2methodsmicromatchmimemime-dbmime-typesmimic-fnmini-css-extract-pluginminimalistic-assertminimatchminimistmkdirpmodule-details-from-pathmrimsmulticast-dnsmznanoidnatural-comparenatural-compare-litenegotiatorneo-asyncnice-tryno-casenode-forgenode-int64node-releasesnormalize-package-datanormalize-pathnormalize-rangenormalize-urlnpm-run-pathnth-checknum2fractionnumber-is-nannwsapiobject-assignobject-hashobject-inspectobject-keysobject.assignobject.entriesobject.fromentriesobject.getownpropertydescriptorsobject.hasownobject.valuesobufon-finishedon-headersonceonetimeopenoptionatorp-finallyp-limitp-locatep-queuep-retryp-timeoutp-tryparam-caseparent-moduleparse-jsonparse5parseurlpascal-casepath-existspath-is-absolutepath-keypath-parsepath-to-regexppath-typeperformance-nowpicocolorspicomatchpidtreepifypinkiepinkie-promisepiratespkg-dirpkg-uppostcsspostcss-attribute-case-insensitivepostcss-browser-commentspostcss-calcpostcss-clamppostcss-color-functional-notationpostcss-color-hex-alphapostcss-color-rebeccapurplepostcss-colorminpostcss-convert-valuespostcss-custom-mediapostcss-custom-propertiespostcss-custom-selectorspostcss-dir-pseudo-classpostcss-discard-commentspostcss-discard-duplicatespostcss-discard-emptypostcss-discard-overriddenpostcss-double-position-gradientspostcss-env-functionpostcss-flexbugs-fixespostcss-focus-visiblepostcss-focus-withinpostcss-font-variantpostcss-gap-propertiespostcss-image-set-functionpostcss-importpostcss-initialpostcss-jspostcss-lab-functionpostcss-load-configpostcss-loaderpostcss-logicalpostcss-media-minmaxpostcss-merge-longhandpostcss-merge-rulespostcss-minify-font-valuespostcss-minify-gradientspostcss-minify-paramspostcss-minify-selectorspostcss-modulespostcss-modules-extract-importspostcss-modules-local-by-defaultpostcss-modules-scopepostcss-modules-valuespostcss-nestedpostcss-nestingpostcss-normalizepostcss-normalize-charsetpostcss-normalize-display-valuespostcss-normalize-positionspostcss-normalize-repeat-stylepostcss-normalize-stringpostcss-normalize-timing-functionspostcss-normalize-unicodepostcss-normalize-urlpostcss-normalize-whitespacepostcss-opacity-percentagepostcss-ordered-valuespostcss-overflow-shorthandpostcss-page-breakpostcss-placepostcss-preset-envpostcss-pseudo-class-any-linkpostcss-reduce-initialpostcss-reduce-transformspostcss-replace-overflow-wrappostcss-selector-notpostcss-selector-parserpostcss-svgopostcss-unique-selectorspostcss-value-parserprelude-lsprettier-linter-helperspretty-bytespretty-errorpretty-formatprocess-nextick-argspromisepromise.seriespromptsprop-typesproxy-addrpslpunycodeqqsquerystringifyqueue-microtaskrafrandombytesrange-parserraw-bodyreact-app-polyfillreact-dev-utilsreact-error-overlayreact-isreact-refreshread-cacheread-pkgreadable-streamreaddirprecursive-readdirregenerateregenerate-unicode-propertiesregenerator-runtimeregenerator-transformregex-parserregexp.prototype.flagsregexppregexpu-coreregjsparserrelateurlrenderkidrequire-directoryrequire-from-stringrequires-portresolveresolve-cwdresolve-fromresolve-url-loaderresolve.exportsretryreusifyrgb-regexrgba-regexrimrafrolluprollup-plugin-babelrollup-plugin-bundle-sizerollup-plugin-es3rollup-plugin-postcssrollup-plugin-smart-assetrollup-plugin-terserrollup-plugin-typescript2rollup-pluginutilsrun-parallelsadesafe-array-concatsafe-buffersafe-identifiersafe-regex-testsafer-buffersanitize.csssass-loadersaxsaxesschedulerschema-utilsselect-hoseselfsignedsemversendserialize-javascriptserve-indexserve-staticset-function-lengthset-function-namesetprototypeofshebang-commandshebang-regexshell-quoteside-channelsignal-exitsimple-swizzlesisteransislashsockjssource-list-mapsource-mapsource-map-jssource-map-loadersource-map-supportsourcemap-codecspdx-correctspdx-exceptionsspdx-expression-parsespdx-license-idsspdyspdy-transportsprintf-jsstablestack-utilsstackframestatic-evalstatusesstring-hashstring-lengthstring-natural-comparestring-widthstring.prototype.matchallstring.prototype.padendstring.prototype.trimstring.prototype.trimendstring.prototype.trimstartstring_decoderstringify-objectstrip-ansistrip-bomstrip-commentsstrip-final-newlinestrip-json-commentsstrip-outerstyle-injectstyle-loaderstylehackssucrasesupports-colorsupports-hyperlinkssupports-preserve-symlinks-flagsvg-parsersvgosymbol-treetailwindcsstapabletemp-dirtempyterminal-linkterserterser-webpack-plugintest-excludetext-tablethenifythenify-allthroatthunkytimsorttiny-globtmplto-fast-propertiesto-regex-rangetoidentifiertough-cookietr46trim-repeatedtryerts-interface-checkertsconfig-pathstslibtsutilstype-checktype-detecttype-festtype-istyped-array-buffertyped-array-byte-lengthtyped-array-byte-offsettyped-array-lengthtypedarray-to-buffertypescriptunbox-primitiveunderscoreundici-typesunicode-canonical-property-names-ecmascriptunicode-match-property-ecmascriptunicode-match-property-value-ecmascriptunicode-property-aliases-ecmascriptuniquniqsunique-stringuniversalifyunpipeunquoteupathupdate-browserslist-dburi-jsurl-parseutil-deprecateutil.promisifyutilautils-mergeuuidv8-compile-cachev8-to-istanbulvalidate-npm-package-licensevaryvendorsvlqw3c-hr-timew3c-xmlserializerwalkerwatchpackwbufwebidl-conversionswebpackwebpack-dev-middlewarewebpack-dev-serverwebpack-manifest-pluginwebpack-sourceswebsocket-driverwebsocket-extensionswhatwg-encodingwhatwg-fetchwhatwg-mimetypewhatwg-urlwhichwhich-boxed-primitivewhich-typed-arrayword-wrapworkbox-background-syncworkbox-broadcast-updateworkbox-buildworkbox-cacheable-responseworkbox-coreworkbox-expirationworkbox-google-analyticsworkbox-navigation-preloadworkbox-precachingworkbox-range-requestsworkbox-recipesworkbox-routingworkbox-strategiesworkbox-streamsworkbox-swworkbox-webpack-pluginworkbox-windowwrap-ansiwrappywrite-file-atomicwsxml-name-validatorxmlcharsy18nyallistyamlyargsyargs-parseryocto-queue
0.1.8

6 months ago

0.1.7

6 months ago