Coder Social home page Coder Social logo

React component about octicons-modular HOT 16 CLOSED

hiendv avatar hiendv commented on May 28, 2024
React component

from octicons-modular.

Comments (16)

M-ZubairAhmed avatar M-ZubairAhmed commented on May 28, 2024

could you provide more information for this issue

from octicons-modular.

hiendv avatar hiendv commented on May 28, 2024

This is solely a nodejs library for now. I'm working on components for specific front-end framework like React or Vue. So we can make it easier to use the library, e.g.

const element = <Octicon :icon="zap" />;

from octicons-modular.

QuadDepo avatar QuadDepo commented on May 28, 2024

How can i help?

from octicons-modular.

hiendv avatar hiendv commented on May 28, 2024

@QuadDepo You may want to implement a React component with tests and examples based on the given idea.

from octicons-modular.

QuadDepo avatar QuadDepo commented on May 28, 2024

sure!

from octicons-modular.

QuadDepo avatar QuadDepo commented on May 28, 2024

Do you want to keep it the same way? rendering SVG or access it with fonts/classes?

from octicons-modular.

hiendv avatar hiendv commented on May 28, 2024

@QuadDepo It should render the SVG with two properties:

  • icon (the octicon object)
  • scale

You may want to see this #5

from octicons-modular.

QuadDepo avatar QuadDepo commented on May 28, 2024

hey man, i worked some stuff out. Still very basic. But after i knew how you were doing it i got the hang of it. Might wanna checkout my fork and check if i'm the in the right direction.

I was thinking of having a .json file with all names and paths to it.

from octicons-modular.

hiendv avatar hiendv commented on May 28, 2024

@QuadDepo First of all, thank you for taking your time addressing this issue. There are things I think we can improve:

  • Bundler: "Use Webpack for apps, and Rollup for libraries". I think it's totally fine to write React components using Rollup. The combination of Webpack and Rollup in a single library is a little bit overwhelming.
  • Validation: We don't need to check for icon existence. The only thing we care is the icon object itself and its svg method. Therefore, we may not need a reference to the icon set.

from octicons-modular.

QuadDepo avatar QuadDepo commented on May 28, 2024

Thanks for the feedback, im not used to use react to build libraries. I will take a look at RollUp.

How do you mean with

we may not need a reference to the icon set.

Is making a .json for the icons a bad thing?

from octicons-modular.

hiendv avatar hiendv commented on May 28, 2024

@QuadDepo I mean this
https://github.com/QuadDepo/octicons-modular/blob/3c94e4c59234fc6360308c24be2133c744e5dd8e/react/src/Octicon.js#L27-L40
We don't have to double check with the icons array in https://github.com/QuadDepo/octicons-modular/blob/3c94e4c59234fc6360308c24be2133c744e5dd8e/react/src/icons.js

from octicons-modular.

QuadDepo avatar QuadDepo commented on May 28, 2024

I think i tried it without it. React throws an error with cant read property of

from octicons-modular.

hiendv avatar hiendv commented on May 28, 2024

@QuadDepo Could you send me the full error stack and a screenshot :D

from octicons-modular.

hiendv avatar hiendv commented on May 28, 2024

@QuadDepo This is an equivalent component to the VueJS one I could think of. Any suggestions?

import PropTypes from 'prop-types'
import { Component } from 'react'
import 'octicons/build/octicons.min.css'

class Octicon extends Component {
  constructor(props) {
    super(props)

    this.state = {
      // No state needed, for now
    }
  }

  render() {
    const {
      icon,
      scale
    } = this.props

    return (
      <span dangerouslySetInnerHTML={ icon.svg({ scale: scale }) }></span>
    )
  }
}

Octicon.propTypes = {
  icon: PropTypes.shape({
    svg: PropTypes.func
  }),
  scale: PropTypes.number
}

Octicon.defaultProps = {
  icon: {
    svg () {
      return
    }
  },
  scale: 1
}

from octicons-modular.

QuadDepo avatar QuadDepo commented on May 28, 2024

Looks good to me.

from octicons-modular.

hiendv avatar hiendv commented on May 28, 2024

@QuadDepo Could you try it with your fork? Thanks.

from octicons-modular.

Related Issues (20)

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.