c-hive / dotdev

Next.js SPA professional website template for teams and individuals: https://c-hive.github.io/dotdev/
MIT License
0 stars 1 forks source link

Issue 25 gh projects imptovement infer tech from language and topics #94

Closed nkapolcs closed 4 years ago

nkapolcs commented 4 years ago

Issue #25
Currently GH project tech info in configurable by hand, but we could extend it so that it can auto-infer some things.

Changes:

Preview: Peek 2020-03-09 23-24

nkapolcs commented 4 years ago

For now, I display the same as the medium, but maybe we could use icons if you prefer.

gomorizsolt commented 4 years ago

On second thought, how about making the logic more "reactish"? :)

const [languageBadges, setLanguageBadges] = useState([]);

useEffect(() => {
   if (githubRepoLanguages.data) {
      const sum = Object.keys(githubRepoLanguages.data).reduce(...);

      // filter the badges according to the treshold
      const badges = // ...

      setLanguageBadges(badges);
   }
}, [githubRepoLanguages.data]);

Please make sure there's no infinite re-renders(because data points to a reference). If so, let's use useMemo().

thisismydesign commented 4 years ago

For now, I display the same as the medium, but maybe we could use icons if you prefer.

This should follow the display setting.

nkapolcs commented 4 years ago

On second thought, how about making the logic more "reactish"? :)

const [languageBadges, setLanguageBadges] = useState([]);

useEffect(() => {
   if (githubRepoLanguages.data) {
      const sum = Object.keys(githubRepoLanguages.data).reduce(...);

      // filter the badges according to the treshold
      const badges = // ...

      setLanguageBadges(badges);
   }
}, [githubRepoLanguages.data]);

Please make sure there's no infinite re-renders(because data points to a reference). If so, let's use useMemo().

Thanks for suggesting. Now I solved it with hooks.

Resolved by a72c1f4

nkapolcs commented 4 years ago

For now, I display the same as the medium, but maybe we could use icons if you prefer.

This should follow the display setting.

Resolved by a72c1f4

nkapolcs commented 4 years ago

How about making this even simpler?

const languages = Object.keys(githubRepoLanguages.data).filter(
    language => {
        const currentNumberOfBytes = githubRepoLanguages.data[language];

        return (
            (currentNumberOfBytes / sumOfNumberOfBytesOfLanguages) * 100 >
            threshold
        );
    }
);

This way you don't need to iterate over the array twice.

Thanks!

Resolved by 0d74fcc