font-awesome-5

Toggling Font Awesome 5 icon with React

大憨熊 提交于 2019-11-30 12:46:55
I am trying to toggle a Font Awesome icon by clicking on a to-do list item. Here is the entire component... import React from 'react'; import './TodoItem.scss'; class TodoItem extends React.Component { constructor(props) { super(props); this.state = { complete: false } this.toggleComplete = this.toggleComplete.bind(this); } toggleComplete() { this.setState(prevState => ({ complete: !prevState.complete })); } render() { const incompleteIcon = <span className="far fa-circle todo-item-icon"></span>; const completeIcon = <span className="far fa-check-circle todo-item-icon"></span>; return ( <div

Font Awesome 5 Bundle via NPM

社会主义新天地 提交于 2019-11-30 11:57:06
问题 I'm trying to bundle only required Font Awesome 5 icons via webpack, but the icons are not replaced in the DOM. I've added all required packages from the documentation: yarn add -D @fortawesome/fontawesome yarn add -D @fortawesome/fontawesome-pro-solid yarn add -D @fortawesome/fontawesome-pro-regular yarn add -D @fortawesome/fontawesome-free-brands The following custom JS is included: "use strict"; import fontawesome from '@fortawesome/fontawesome'; import faCheck from '@fortawesome

Switch between icons when using FontAwesome 5.0 SVG Framework

。_饼干妹妹 提交于 2019-11-30 03:28:54
I'm looking to be able to switch between icons in Javascript while using the new FontAwesome SVG framework. Previously in the old WebFont method, this was achieved by toggling or changing the class on the tag, however as these are now rendered as SVG's in the source code this no longer works. Is there a way to do this without needing to render both SVG icons in source code and using additional classes/CSS to toggle display? Pascal Font Awesome 5.0.0 has just been released and the migration from 4.7 to 5.0 wrecked up my javascript/jquery to change a "fa-star-o" icon to "fa-star" when the user

Font Awesome 5 Bundle via NPM

孤街浪徒 提交于 2019-11-30 01:45:07
I'm trying to bundle only required Font Awesome 5 icons via webpack, but the icons are not replaced in the DOM. I've added all required packages from the documentation : yarn add -D @fortawesome/fontawesome yarn add -D @fortawesome/fontawesome-pro-solid yarn add -D @fortawesome/fontawesome-pro-regular yarn add -D @fortawesome/fontawesome-free-brands The following custom JS is included: "use strict"; import fontawesome from '@fortawesome/fontawesome'; import faCheck from '@fortawesome/fontawesome-pro-regular/faCheck'; fontawesome.icon(faCheck); function iconsDoneRendering () { console.log(

Font awesome 5 on pseudo elements

我的未来我决定 提交于 2019-11-29 19:43:34
In font awesome 4 you could easily apply an icon to a :before/:after element using CSS. Is the same possible with the new font awesome 5 JS/SVG implementation? As from what i can see this requires the relevant tag to exist in html which isn't always practical e.g. you have a CMS and want to apply an icon to all user created content <li> elements I know in FA5 you can still use the old css/webfonts but it would be nice if the same functionality was available in the recommended method of using JS You need to enable it (it's disabled by default). <script> window.FontAwesomeConfig = {

Toggling Font Awesome 5 icon with React

烈酒焚心 提交于 2019-11-29 17:49:11
问题 I am trying to toggle a Font Awesome icon by clicking on a to-do list item. Here is the entire component... import React from 'react'; import './TodoItem.scss'; class TodoItem extends React.Component { constructor(props) { super(props); this.state = { complete: false } this.toggleComplete = this.toggleComplete.bind(this); } toggleComplete() { this.setState(prevState => ({ complete: !prevState.complete })); } render() { const incompleteIcon = <span className="far fa-circle todo-item-icon"><

How can I get Font Awesome 5 to work with React?

北战南征 提交于 2019-11-29 11:47:49
In the following example, the initial icon renders but it does not change when the class changes. const Circle = ({ filled, onClick }) => { const className = filled ? 'fas fa-circle' : 'far fa-circle'; return ( <div onClick={onClick} > <i className={className} /> <p>(class is {className})</p> </div> ); }; class App extends React.Component { state = { filled: false }; handleClick = () => { this.setState({ filled: !this.state.filled }); }; render() { return <Circle filled={this.state.filled} onClick={this.handleClick} />; } } ReactDOM.render(<App />, document.getElementById("root")); <script src

Prevent svg translation of fontawesome

不想你离开。 提交于 2019-11-29 04:37:30
I have en issue with angular and font awesome. On first generation of list of icons suddenly all css class based icons are translated to svg. It affects only solid icons. for example : <i class="fas fa-2x fa-minus-square"></i> is translated somehow to <svg _ngcontent-c16="" class="svg-inline--fa fa-minus-square fa-w-14 fa-2x" ng-reflect-ng-class="fas fa-2x fa-minus-square" aria-hidden="true" data-prefix="fas" data-icon="minus-square" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg=""> <path fill="currentColor" d="M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5

Switch between icons when using FontAwesome 5.0 SVG Framework

天大地大妈咪最大 提交于 2019-11-29 00:59:53
问题 I'm looking to be able to switch between icons in Javascript while using the new FontAwesome SVG framework. Previously in the old WebFont method, this was achieved by toggling or changing the class on the tag, however as these are now rendered as SVG's in the source code this no longer works. Is there a way to do this without needing to render both SVG icons in source code and using additional classes/CSS to toggle display? 回答1: Font Awesome 5.0.0 has just been released and the migration from

How can I get Font Awesome 5 to work with React?

…衆ロ難τιáo~ 提交于 2019-11-28 05:01:32
问题 In the following example, the initial icon renders but it does not change when the class changes. const Circle = ({ filled, onClick }) => { const className = filled ? 'fas fa-circle' : 'far fa-circle'; return ( <div onClick={onClick} > <i className={className} /> <p>(class is {className})</p> </div> ); }; class App extends React.Component { state = { filled: false }; handleClick = () => { this.setState({ filled: !this.state.filled }); }; render() { return <Circle filled={this.state.filled}