Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new icons for Social Icon widget and custom icon #4354

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions assets/apps/components/src/Common/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,82 @@ const getIcons = (size) => {
/>
</svg>
),
medium: (
<svg
width={size}
height={size}
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 640 512"
>
<path d="M180.5 74.3C80.8 74.3 0 155.6 0 256S80.8 437.7 180.5 437.7 361 356.4 361 256 280.2 74.3 180.5 74.3zm288.3 10.6c-49.8 0-90.2 76.6-90.2 171.1s40.4 171.1 90.3 171.1 90.3-76.6 90.3-171.1H559C559 161.5 518.6 84.9 468.8 84.9zm139.5 17.8c-17.5 0-31.7 68.6-31.7 153.3s14.2 153.3 31.7 153.3S640 340.6 640 256C640 171.4 625.8 102.7 608.3 102.7z" />
</svg>
),
bluesky: (
<svg
width={size}
height={size}
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
>
<path d="M111.8 62.2C170.2 105.9 233 194.7 256 242.4c23-47.6 85.8-136.4 144.2-180.2c42.1-31.6 110.3-56 110.3 21.8c0 15.5-8.9 130.5-14.1 149.2C478.2 298 412 314.6 353.1 304.5c102.9 17.5 129.1 75.5 72.5 133.5c-107.4 110.2-154.3-27.6-166.3-62.9l0 0c-1.7-4.9-2.6-7.8-3.3-7.8s-1.6 3-3.3 7.8l0 0c-12 35.3-59 173.1-166.3 62.9c-56.5-58-30.4-116 72.5-133.5C100 314.6 33.8 298 15.7 233.1C10.4 214.4 1.5 99.4 1.5 83.9c0-77.8 68.2-53.4 110.3-21.8z" />
</svg>
),
'square-bluesky': (
<svg
width={size}
height={size}
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 448 512"
>
<path d="M64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l320 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zM224 247.4c14.5-30 54-85.8 90.7-113.3c26.5-19.9 69.3-35.2 69.3 13.7c0 9.8-5.6 82.1-8.9 93.8c-11.4 40.8-53 51.2-90 44.9c64.7 11 81.2 47.5 45.6 84c-67.5 69.3-97-17.4-104.6-39.6c0 0 0 0 0 0l-.3-.9c-.9-2.6-1.4-4.1-1.8-4.1s-.9 1.5-1.8 4.1c-.1 .3-.2 .6-.3 .9c0 0 0 0 0 0c-7.6 22.2-37.1 108.8-104.6 39.6c-35.5-36.5-19.1-73 45.6-84c-37 6.3-78.6-4.1-90-44.9c-3.3-11.7-8.9-84-8.9-93.8c0-48.9 42.9-33.5 69.3-13.7c36.7 27.5 76.2 83.4 90.7 113.3z" />
</svg>
),
threads: (
<svg
width={size}
height={size}
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 448 512"
>
<path d="M331.5 235.7c2.2 .9 4.2 1.9 6.3 2.8c29.2 14.1 50.6 35.2 61.8 61.4c15.7 36.5 17.2 95.8-30.3 143.2c-36.2 36.2-80.3 52.5-142.6 53h-.3c-70.2-.5-124.1-24.1-160.4-70.2c-32.3-41-48.9-98.1-49.5-169.6V256v-.2C17 184.3 33.6 127.2 65.9 86.2C102.2 40.1 156.2 16.5 226.4 16h.3c70.3 .5 124.9 24 162.3 69.9c18.4 22.7 32 50 40.6 81.7l-40.4 10.8c-7.1-25.8-17.8-47.8-32.2-65.4c-29.2-35.8-73-54.2-130.5-54.6c-57 .5-100.1 18.8-128.2 54.4C72.1 146.1 58.5 194.3 58 256c.5 61.7 14.1 109.9 40.3 143.3c28 35.6 71.2 53.9 128.2 54.4c51.4-.4 85.4-12.6 113.7-40.9c32.3-32.2 31.7-71.8 21.4-95.9c-6.1-14.2-17.1-26-31.9-34.9c-3.7 26.9-11.8 48.3-24.7 64.8c-17.1 21.8-41.4 33.6-72.7 35.3c-23.6 1.3-46.3-4.4-63.9-16c-20.8-13.8-33-34.8-34.3-59.3c-2.5-48.3 35.7-83 95.2-86.4c21.1-1.2 40.9-.3 59.2 2.8c-2.4-14.8-7.3-26.6-14.6-35.2c-10-11.7-25.6-17.7-46.2-17.8H227c-16.6 0-39 4.6-53.3 26.3l-34.4-23.6c19.2-29.1 50.3-45.1 87.8-45.1h.8c62.6 .4 99.9 39.5 103.7 107.7l-.2 .2zm-156 68.8c1.3 25.1 28.4 36.8 54.6 35.3c25.6-1.4 54.6-11.4 59.5-73.2c-13.2-2.9-27.8-4.4-43.4-4.4c-4.8 0-9.6 .1-14.4 .4c-42.9 2.4-57.2 23.2-56.2 41.8l-.1 .1z" />
</svg>
),
'square-threads': (
<svg
width={size}
height={size}
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 448 512"
>
<path d="M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64zM294.2 244.3c19.5 9.3 33.7 23.5 41.2 40.9c10.4 24.3 11.4 63.9-20.2 95.4c-24.2 24.1-53.5 35-95.1 35.3h-.2c-46.8-.3-82.8-16.1-106.9-46.8C91.5 341.8 80.4 303.7 80 256v-.1-.1c.4-47.7 11.5-85.7 33-113.1c24.2-30.7 60.2-46.5 106.9-46.8h.2c46.9 .3 83.3 16 108.2 46.6c12.3 15.1 21.3 33.3 27 54.4l-26.9 7.2c-4.7-17.2-11.9-31.9-21.4-43.6c-19.4-23.9-48.7-36.1-87-36.4c-38 .3-66.8 12.5-85.5 36.2c-17.5 22.3-26.6 54.4-26.9 95.5c.3 41.1 9.4 73.3 26.9 95.5c18.7 23.8 47.4 36 85.5 36.2c34.3-.3 56.9-8.4 75.8-27.3c21.5-21.5 21.1-47.9 14.2-64c-4-9.4-11.4-17.3-21.3-23.3c-2.4 18-7.9 32.2-16.5 43.2c-11.4 14.5-27.7 22.4-48.4 23.5c-15.7 .9-30.8-2.9-42.6-10.7c-13.9-9.2-22-23.2-22.9-39.5c-1.7-32.2 23.8-55.3 63.5-57.6c14.1-.8 27.3-.2 39.5 1.9c-1.6-9.9-4.9-17.7-9.8-23.4c-6.7-7.8-17.1-11.8-30.8-11.9h-.4c-11 0-26 3.1-35.6 17.6l-23-15.8c12.8-19.4 33.6-30.1 58.5-30.1h.6c41.8 .3 66.6 26.3 69.1 71.8c1.4 .6 2.8 1.2 4.2 1.9l.1 .5zm-71.8 67.5c17-.9 36.4-7.6 39.7-48.8c-8.8-1.9-18.6-2.9-29-2.9c-3.2 0-6.4 .1-9.6 .3c-28.6 1.6-38.1 15.5-37.4 27.9c.9 16.7 19 24.5 36.4 23.6l-.1-.1z" />
</svg>
),
substack: (
<svg
width={size}
height={size}
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
>
<path d="M15 3.604H1v1.891h14v-1.89ZM1 7.208V16l7-3.926L15 16V7.208zM15 0H1v1.89h14z" />
</svg>
),
linktree: (
<svg
width={size}
height={size}
xmlns="http://www.w3.org/2000/svg"
x="0px"
y="0px"
viewBox="0 0 80 97.7"
xmlSpace="preserve"
>
<path
d="M0.2,33.1h24.2L7.1,16.7l9.5-9.6L33,23.8V0h14.2v23.8L63.6,7.1l9.5,9.6L55.8,33H80v13.5H55.7l17.3,16.7l-9.5,9.4L40,49.1
L16.5,72.7L7,63.2l17.3-16.7H0V33.1H0.2z M33.1,65.8h14.2v32H33.1V65.8z"
></path>
</svg>
),
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import {
ToggleControl,
TextareaControl,
ExternalLink,
ButtonGroup,
Placeholder,
} from '@wordpress/components';
import IconSelector from './IconSelector';
import { getIcons, ColorControl } from '@neve-wp/components';
import PropTypes from 'prop-types';
import { __ } from '@wordpress/i18n';
import Range from '../range/Range';
import { MediaUpload } from '@wordpress/media-utils';

const RepeaterItemContent = ({
fields,
Expand Down Expand Up @@ -163,14 +166,97 @@ const RepeaterItemContent = ({
{...fields[key]}
/>
);
case 'switcher':
return <Switcher fieldId={key} currentField={currentField} />;
case 'media':
return (
<Placeholder
icon="format-image"
label={__('Custom Icon', 'neve')}
>
{!value[index][key] ? (
<>
<p>
{__(
'Select from the Media Library or upload a new image',
'neve'
)}
</p>
<MediaUpload
onSelect={(imageData) => {
changeContent(key, imageData.url);
}}
allowedTypes={['image']}
render={({ open }) => (
<Button isSecondary onClick={open}>
{__('Add Image', 'neve')}
</Button>
)}
/>
</>
) : (
<>
<img src={value[index][key]} alt="icon" />
<Button
disabled={!wp.media}
className="remove-image"
isDestructive
isSecondary
onClick={() => {
changeContent(key, '');
}}
>
{__('Remove Image', 'neve')}
</Button>
</>
)}
</Placeholder>
);
}
};

const Switcher = ({ fieldId, currentField }) => {
const selectedOption =
value[index][fieldId] || Object.keys(currentField.options)[0];

return (
<>
<ButtonGroup className="neve-background-type-control">
{Object.entries(currentField.options).map(
([optionKey, option]) => {
return (
<Button
key={optionKey}
isPrimary={optionKey === selectedOption}
isSecondary={optionKey !== selectedOption}
onClick={() => {
changeContent(fieldId, optionKey);
}}
>
{option.label}
</Button>
);
}
)}
</ButtonGroup>
{currentField.options?.[selectedOption]?.fields.map(
(componentId) => {
return toComponent(componentId, value[index]);
}
)}
</>
);
};

return (
<div className="nv-repeater-content">
{Object.entries(currentFields).map(([key]) => {
return toComponent(key, value[index]);
})}
{Object.entries(currentFields)
.filter(([, options]) => {
return !options?.parent;
})
.map(([key]) => {
return toComponent(key, value[index]);
})}
{value.length > 1 && !isBlocked && (
<Button
className="nv-repeater-remove-button"
Expand Down
Loading