Skip to content

Commit

Permalink
feat: Add Icon component
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbiscuit committed Mar 30, 2023
1 parent 7b1ece5 commit 152a44f
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 4 deletions.
13 changes: 13 additions & 0 deletions src/components/Icon/Icon.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import '@affinitic/volto-icon-selector-widget/styles/style.less';

const Icon = (props) => {
const { name, size } = props;
const formatedName = name
.split(' ')
.map((separetedName) => `fa-${separetedName}`)
.join(' ');
return <i className={`af-icon fa-solid ${formatedName} ${size}`}></i>;
};

export default Icon;
3 changes: 3 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Icon from './Icon/Icon';

export { Icon };
3 changes: 2 additions & 1 deletion src/default/ResultRenderer.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Icon, Popup } from 'semantic-ui-react';
import { Popup } from 'semantic-ui-react';
import { Icon } from '@affinitic/volto-icon-selector-widget/components';

const ResultRenderer = (props) => {
return <Popup trigger={<Icon name={props.name} />}>{props.name}</Popup>;
Expand Down
50 changes: 50 additions & 0 deletions src/styles/af-icon.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
i.mini.af-icon,
i.mini.af-icons {
font-size: @mini;
line-height: 1;
}

i.tiny.af-icon,
i.tiny.af-icons {
font-size: @tiny;
line-height: 1;
}

i.small.af-icon,
i.small.af-icons {
font-size: @small;
line-height: 1;
}

i.af-icon,
i.af-icons {
font-size: @medium;
}

i.large.af-icon,
i.large.af-icons {
font-size: @large;
line-height: 1;
vertical-align: middle;
}

i.big.af-icon,
i.big.af-icons {
font-size: @big;
line-height: 1;
vertical-align: middle;
}

i.huge.af-icon,
i.huge.af-icons {
font-size: @huge;
line-height: 1;
vertical-align: middle;
}

i.massive.af-icon,
i.massive.af-icons {
font-size: @massive;
line-height: 1;
vertical-align: middle;
}
1 change: 1 addition & 0 deletions src/styles/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import './fontawesome/brands.less';

@import 'variables';
@import 'af-icon';

@fa-font-path: '../webfonts';

Expand Down
2 changes: 1 addition & 1 deletion src/view/IconSelectorWidget.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import cx from 'classnames';
import { Icon } from 'semantic-ui-react';
import { Icon } from '@affinitic/volto-icon-selector-widget/components';

const IconSelectorWidget = (props) => {
const { value, className } = props;
Expand Down
4 changes: 2 additions & 2 deletions src/widget/IconSelectorWidget.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import _ from 'lodash';
import React, { useState } from 'react';
import { FormFieldWrapper } from '@plone/volto/components';
import { Search, Icon } from 'semantic-ui-react';
import { Search } from 'semantic-ui-react';
import { Icon } from '@affinitic/volto-icon-selector-widget/components';
import { useIntl, defineMessages } from 'react-intl';
import config from '@plone/volto/registry';
import '../styles/style.less';

const messages = defineMessages({
placeholder: {
Expand Down

0 comments on commit 152a44f

Please sign in to comment.