Coder Social home page Coder Social logo

junaidbhura / gumponents Goto Github PK

View Code? Open in Web Editor NEW
52.0 2.0 7.0 2.26 MB

Essential Gutenberg components for WordPress.

Home Page: https://junaid.dev

License: MIT License

JavaScript 58.84% PHP 23.65% Shell 6.68% SCSS 10.83%
gutenberg wordpress react gutenberg-components

gumponents's Introduction

GitHub Actions

Gumponents!

Essential Gutenberg components for WordPress.

Gumponents offer some crucial missing Gutenberg components, essential to create advanced blocks. ๐Ÿš€

Individual Gumponents aim to be deprecated over time, when components similar or better land in WordPress core.

They are not blocks, but rather, what you would use to build advanced blocks.

Quick Links

Documentation | Roadmap

Components

PostRelationshipControl

post-relationship-control

Example

const { PostRelationshipControl } = gumponents.components;

<PostRelationshipControl
	label="Select people"
	help="Select people"
	postTypes="people"
	taxonomies={ [ { people_roles: [ 'ceo', 'management' ] } ] }
	value={ people.map( person => person.ID ) }
	onSelect={ people => setAttributes( { people } ) }
	buttonLabel="Select People"
	filter="people_meta"
	max="1"
/>

TaxonomyRelationshipControl

taxonomy-relationship-control

Example

const { TaxonomyRelationshipControl } = gumponents.components;

<TaxonomyRelationshipControl
	label="Select people roles"
	taxonomies="people_roles"
	value={ taxonomy.map( tax => tax.term_id ) }
	onSelect={ taxonomy => setAttributes( { taxonomy } ) }
	buttonLabel="Select People Roles"
	filter="people_meta"
	max="1"
/>

ColorPaletteControl

color-palette-control

Example

const { ColorPaletteControl } = gumponents.components;

...

attributes: {
	color: {
		type: 'object',
	},
},
...

<ColorPaletteControl
	label="Choose a color"
	value={ color ? color.color : null }
	onChange={ color => setAttributes( { color } ) }
/>

MultiSelectControl

multi-select-control

Example

const { MultiSelectControl } = gumponents.components;

...

attributes: {
	simpsons: {
		type: 'array',
		default: [],
	},
},

...

const options = [
	{ value: 'bart', label: 'Bart' },
	{ value: 'homer', label: 'Homer' },
	{ value: 'marge', label: 'Marge' },
];

<MultiSelectControl
	label="Choose Simpsons"
	help="Choose your favorite characters."
	options={ options }
	value={ attributes.simpsons }
	onChange={ ( simpsons ) => setAttributes( { simpsons } ) }
	placeholder="D'oh"
/>

LinkControl

link-control

Example

const { LinkControl } = gumponents.components;

...

attributes: {
	link: {
		type: 'object',
		default: {},
	},
},

...

<LinkControl
	label="Select URL"
	value={ attributes.link }
	onChange={ ( link ) => setAttributes( { link } ) }
	help="Enter a URL."
/>

FileControl

file-control

Example

const { FileControl } = gumponents.components;

...

attributes: {
	file: {
		type: 'object',
		default: null,
	},
},

...

<FileControl
	label="Choose file"
	selectLabel="Choose video"
	removeLabel="Remove this video"
	onChange={ file => setAttributes( { file: file ? { id: file.id, name: file.filename } : null } ) }
	value={ file ? file.id : null }
/>

ImageControl

image-control

Example

const { ImageControl } = gumponents.components;

...

attributes: {
	image: {
		type: 'object',
		default: null,
	},
},

...

<ImageControl
	label="Choose image"
	selectLabel="Choose image"
	removeLabel="Remove this image"
	size="thumbnail"
	value={ image }
	onChange={ ( image, media ) => setAttributes( { image } ) }
/>

FocalPointPickerControl

focal-point-picker

Example

const { FocalPointPickerControl } = gumponents.components;

...

attributes: {
	image: {
		type: 'object',
	        default: {},
	},
	focalPoint: {
		type: 'object',
	        default: {},
	},
},

...

<FocalPointPickerControl
	label="Focal Point"
	imageUrl={ attributes.image.src }
	value={ attributes.focalPoint }
	help="Choose a focal point"
	onChange={ ( focalPoint ) => setAttributes( { focalPoint } ) }
/>

GalleryControl

gallery-control

Example

const { GalleryControl } = gumponents.components;

...

attributes: {
	gallery: {
		type: 'array',
		default: [],
	},
},

...

<GalleryControl
	size="medium"
	onSelect={ ( gallery, media ) => {
		setAttributes( { gallery: null } ); // The block editor doesn't update arrays correctly? ๐Ÿคทโ€โ™‚๏ธ
		setAttributes( { gallery } );
	} }
	value={ attributes.gallery }
/>

LinkButton

link-button

Example

const { LinkButton } = gumponents.components;

...

attributes: {
	link: {
		type: 'object',
	},
},

...

<LinkButton
	className="btn btn--primary"
	placeholder="Select Link"
	value={ attributes.link }
	onChange={ ( link ) => setAttributes( { link } ) }
/>

SelectImage

select-image

Example

const { SelectImage } = gumponents.components;

...

attributes: {
	image: {
		type: 'object',
		default: null,
	},
},

...

<SelectImage
	image={ image }
	placeholder="Choose an image"
	size="full"
	onChange={ ( image, media ) => {
		setAttributes( { image: null } ); // The block editor doesn't update objects correctly? ๐Ÿคทโ€โ™‚๏ธ
		setAttributes( { image } );
	} }
	showCaption={ false }
/>

gumponents's People

Contributors

abhi3315 avatar ghoshprithwi avatar i-am-chitti avatar imranhsayed avatar junaidbhura avatar thelovekesh avatar xandercalvert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gumponents's Issues

New Notice with WP 5.8

The following error is now appearing with your plugin, I think it ist related to your wp_enqueue_script setting wp-editor as a dep. The error appears on the new widget edit page, any ideas?

Notice: wp_enqueue_script() was called incorrectly. "wp-editor" script should not be enqueued together with the new widgets editor (wp-edit-widgets or wp-customize-widgets). [โ€ฆ]

URL Control

Add a URL control which is a wrapper for <URLInput />

GalleryControl

Create a control which allows the user to select a gallery of images.

Any plans to release as an NPM package?

Sorry, I didn't know where to post this but I was wondering if you had any plans to release this as a package rather than a plugin. I love the components you offer but feel it would work better in my (and possibly others'?) workflow if I could pull it in as a dependency.

Working with clients, the risk is that somewhere down the line, they disable unrecognized plugins and break things.

Improvements to PostRelationshipControl

The following improvements can be made to PostRelationshipControl:

  1. Allow it to show post thumbnails in results
  2. Add a filter for post types
  3. UI improvements for de-selecting posts, messages for maximum or minimum posts
  4. Add a minimum selection

Multi-select control

An easy to use multi-select control would be useful.

Drag and drop reorder, AJAX / API autocomplete.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.