<i class="field"><svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
<path d="m55 63h-46a1 1 0 0 1 -1-1v-60a1 1 0 0 1 1-1h46a1 1 0 0 1 1 1v60a1 1 0 0 1 -1 1zm-45-2h44v-58h-44z" />
<path d="m37 11h-10a1 1 0 0 1 -1-1v-4a1 1 0 0 1 2 0v3h8v-3a1 1 0 0 1 2 0v4a1 1 0 0 1 -1 1z" />
<path d="m32 16a1 1 0 0 1 -1-1v-5a1 1 0 0 1 2 0v5a1 1 0 0 1 -1 1z" />
<path d="m37 59a1 1 0 0 1 -1-1v-3h-8v3a1 1 0 0 1 -2 0v-4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1z" />
<path d="m32 55a1 1 0 0 1 -1-1v-5a1 1 0 0 1 2 0v5a1 1 0 0 1 -1 1z" />
<path d="m50 33h-36a1 1 0 0 1 0-2h36a1 1 0 0 1 0 2z" />
<path d="m50 16h-36a1 1 0 0 1 0-2h36a1 1 0 0 1 0 2z" />
<path d="m50 50h-36a1 1 0 0 1 0-2h36a1 1 0 0 1 0 2z" />
<path d="m50 24h-2a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2z" />
<path d="m50 28h-2a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2z" />
<path d="m50 20h-2a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2z" />
<path d="m50 42h-2a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2z" />
<path d="m50 46h-2a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2z" />
<path d="m50 38h-2a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2z" />
<path d="m16 24h-2a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2z" />
<path d="m16 28h-2a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2z" />
<path d="m16 20h-2a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2z" />
<path d="m16 42h-2a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2z" />
<path d="m16 46h-2a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2z" />
<path d="m16 38h-2a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2z" />
</svg></i>
{% set className = className ? className ~ ' ' : '' %}
{% set attributes = className ~ icon | trim %}
{% set insert = true %}
{% if iconType is empty or iconType == 'custom' %}
<i class="{{ attributes }}">{% if insert is defined and insert == true %}{{ source('@customIcons/' ~ icon ~ '.svg') }}{% endif %}</i>
{% elseif iconType is not empty or iconType == 'iconoir' %}
<i class="{{ attributes }}">{% if insert is defined and insert == true %}{{ source('@icons/' ~ icon ~ '.svg') }}{% endif %}</i>
{% endif %}
{
"icon": "field"
}
<?php
namespace Theme\Views\Atoms\icon;
use ACFToolkit\Traits\SetWrapperWidth;
use ACFToolkit\Types\CustomAtom;
class Icon extends CustomAtom
{
use SetWrapperWidth;
public string $name = 'icon';
public string $label = 'Icon';
public int $needsJs = 0;
public int $needsVue = 1;
public int $needsVueInitialisation = 0;
public function __construct($name = '', $title = '', $children = [])
{
parent::__construct($name, $title);
$this->addChildren(array_merge($children, [
]));
}
public function getChoices()
{
$customIcons = get_template_directory().'/resources/Views/Assets/dist/custom-icons/*.svg';
$result = [];
$files = glob($customIcons);
foreach($files as $file) {
$filename = basename($file, '.svg');
$result[$filename] = $filename;
}
return $result;
}
}
<?php
namespace Theme\Views\Atoms\icon;
use ACFToolkit\ViewModels\BaseViewModel;
class IconViewModel extends BaseViewModel
{
}
i {
display: inline-block;
width: 26px;
svg {
width: 100%;
vertical-align: top;
}
&.sm {
width: 20px;
}
&.md {
width: 40px;
}
&.lg {
width: 50px;
}
&.xl {
width: 60px;
}
&.star--filled {
svg {
g {
fill: theme('colors.primary');
}
}
}
&.logo {
svg {
g {
fill: theme('colors.primary');
}
}
}
&.logo--white {
svg {
g {
fill: #fff;
}
}
}
&.logo_subline {
svg {
g {
fill: theme('colors.primary');
}
}
}
&.logo_subline--white {
svg {
g {
fill: #fff;
}
}
}
&.logo_subline-subline--accent {
svg {
g {
fill: theme('colors.primary');
&#subline {
fill: theme('colors.accent');
}
}
}
}
&.logo_subline--white-subline--accent {
svg {
g {
fill: #fff;
&#subline {
fill: theme('colors.accent');
}
}
}
}
&.search {
width: 24px;
height: 24px;
}
}
<template>
<i
:class="getTypeClass + '-' + icon + ' ' + className"
v-html="iconSource"
:title="title"
v-if="iconSource"
></i>
</template>
<script>
import IconService from '../../Assets/src/js/services/IconService';
export default {
props: {
className: {
type: String,
default: ''
},
icon: {
type: String,
},
title: {
type: String
},
type: {
type: String,
default: 'custom'
}
},
data: () => {
return {
iconSource: null
}
},
computed: {
getTypeClass(){
return this.type === 'custom' ? 'custom' : 'iconoir'
}
},
async created(){
const {data} = this.type === 'custom' ?
await IconService.getCustom(this.icon) :
await IconService.getIconoir(this.icon)
this.iconSource = data
}
}
</script>
<style>
*[class^="iconoir-"], *[class*=" iconoir-"] {
display: inline-block;
}
</style>
{% include '@atoms/icon/icon.twig' with {
icon: 'icon'
} only %}Fields