react-icons/go#GoOrganization JavaScript Examples

The following examples show how to use react-icons/go#GoOrganization. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Stats.js    From gitpedia with MIT License 4 votes vote down vote up
Stats = ({ userData, repoData }) => {
    const [starData, setStarData] = useState({});
    const [sizeData, setSizeData] = useState({});
    const [totalStars, setTotalStars] = useState(null);

    useEffect(() => {
        const getMostStarredRepos = () => {
            const LIMIT = 5;
            const sortProperty = "stargazers_count";
            const mostStarredRepos = repoData
                .filter((repo) => !repo.fork)
                .sort((a, b) => b[sortProperty] - a[sortProperty])
                .slice(0, LIMIT);

            // Label and data needed for  displaying Charts
            const label = mostStarredRepos.map((repo) => repo.name);
            const data = mostStarredRepos.map((repo) => repo[sortProperty]);

            setStarData({ label, data });
        };

        const getTotalStars = () => {
            const myRepos = repoData
                .filter((repo) => !repo.fork)
                .map((repo) => repo.stargazers_count);
            const totalStars = myRepos.reduce((a, b) => a + b, 0);

            setTotalStars(totalStars);
        };

        const getMaxSizeRepos = () => {
            const LIMIT = 5;
            const sortProperty = "size";
            const mostStarredRepos = repoData
                .filter((repo) => !repo.fork)
                .sort((a, b) => b[sortProperty] - a[sortProperty])
                .slice(0, LIMIT);

            const label = mostStarredRepos.map((repo) => repo.name);
            const data = mostStarredRepos.map((repo) => repo[sortProperty]);

            setSizeData({ label, data });
        };

        if (repoData.length) {
            getMostStarredRepos();
            getMaxSizeRepos();
            getTotalStars();
        }
    }, [repoData]);

    return (
        <>
            <StatsContainer>
                <StatsDiv primary>
                    <div>
                        <GoRepo />
                        <IconSpan>Repositories</IconSpan>
                    </div>
                    <h2>{userData.public_repos}</h2>
                </StatsDiv>
                <StatsDiv secondary>
                    <div>
                        <GoStar />
                        <IconSpan>Total Stars</IconSpan>
                    </div>
                    <h2>{totalStars}</h2>
                </StatsDiv>
                <StatsDiv tertiary>
                    <div>
                        <GoOrganization />
                        <IconSpan>Followers</IconSpan>
                    </div>
                    <h2>{userData.followers}</h2>
                </StatsDiv>
                <StatsDiv quad>
                    <div>
                        <GoPerson />
                        <IconSpan>Following</IconSpan>
                    </div>
                    <h2>{userData.following}</h2>
                </StatsDiv>
            </StatsContainer>

            <RoundChartContainer>
                <ChartDiv chart1>
                    <ChartHeading>Largest in Size(kb)</ChartHeading>
                    <BarChart sizeData={sizeData} />
                </ChartDiv>
                <ChartDiv>
                    <ChartHeading>Top Languages</ChartHeading>
                    <DoughnutChart />
                </ChartDiv>
                <ChartDiv chart3>
                    <ChartHeading>Most Starred</ChartHeading>
                    <PieChart starData={starData} width={100} />
                </ChartDiv>
            </RoundChartContainer>
        </>
    );
}