Giter Club home page Giter Club logo

react-flagpack's Introduction

Flagpack

Flagpack contains 250+ flag icons to easily use within your code project. Flagpack is an open source project and available for JavaScript frameworks/libraries React, Vue and Svelte.

Flagpack. 260+ easily implementable flag icons to use in your design or code project. Open Source. Available for Sketch, Figma, Angular, Vue, and React. www.flagpack.xyz. Made with love by Yummygum. Graphic showing a list with the flags of Argentina, Croatia, Estonia, Kenia, Netherlands, and Scotland.

View documentation on flagpack.xyz

react-flagpack

Flagpack for React is created using React v16.8. The Flagpack component has not been tested for compatibility with older versions of React.

Installation

$: npm install react-flagpack --save

Usage

Defining the component

Import the Flagpack component into any of your project's React components.

import Flag from 'react-flagpack'

Use in JSX

<Flag
  code="NL"
  gradient="real-linear"
  size="m"
  hasDropShadow
/>

Available component configurations — Props

Key Value Required Default Format
code String false 'NL' See all codes
size String false 'L' 'S', 'M' or 'L'
className String false - -
hasDropShadow Boolean false false -
hasBorder Boolean false true -
hasBorderRadius Boolean false true -
gradient String false '' 'top-down', 'real-linear' or 'real-circular'

Support

Frequently Asked Questions

Documentation

Releases

You can find a changelog of Flagpack's releases on the Releases page on GitHub.

Contribute

If you're interested in contributing to this project, great! Please see the contributing document how to set up you up.

License

Flagpack is an open source project published under a MIT license.

react-flagpack's People

Contributors

daoneandonly avatar dependabot[bot] avatar fredericbonnet avatar noudadrichem avatar zoeyfrisart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-flagpack's Issues

Some flags are missing with different sizes

If I choose size="M" or size="S" my app crashesh with the follow error:

Error: Cannot find module './S/AD.svg'
Error: Cannot find module './M/AD.svg'

I'm using webpack with create-react-app craco.

Here are all the codes I'm using

["AD", "AE", "AFRUN", "AG", "AI", "AL", "AM", "AMS", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ-BO", "BQ-SA", "BQ-SE", "BR", "BS", "BT", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "EU", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB-ENG", "GB-SCT", "GB-UKM", "GB-WLS", "GB-NIR", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN-SK", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RAINBOW", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "UNASUR", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "ZA", "ZM", "ZW", "AF", "BV"];

Usage with Next.js

Hi there!

I would like to use the flag library in my Next.js project but unfortunately I keep getting the following error as soon as I use the Flag component:

<svg width="32" height="24" viewBox="0 0 32 24" fill="none" xmlns="http://www.w3.org/2000/svg">
^

SyntaxError: Unexpected token '<'
    at wrapSafe (node:internal/modules/cjs/loader:1018:16)

I have looked into fixing this issue with Next.js but unfortunately I have tried many different solutions, even tried this package. But this didn't work for me.

I am wondering if anyone else has similar issues with using this library in combination with Next.js and would love to hear if someone figures it out how to fix this issue.

Thanks a lot, the library looks really good and would love to use it!

Edit: I am using Next.js v10.0.3

TS: export 'default' (imported as 'Flag') was not found in 'react-flagpack' (module has no exports)

Hi,

I just updated flagpack and I get this error when trying to import the Flag Component:

import Flag from 'react-flagpack'

I tried fixing it for a few hours, but I'm at my witts end.

I use react + typescript with webpack 5.

error looks like this:

WARNING in ./src/app/Widgets/DualCountryFlag.tsx 14:36-40
export 'default' (imported as 'Flag') was not found in 'react-flagpack' (module has no exports)
 @ ./src/app/CertificateViewer/rowInput.tsx 15:0-57 148:36-51

Any help would be appreciated :)

Broken release 1.1.0

Please check all that apply

  • visual bug
  • functional bug
  • able to consistently reproduce

Current Behavior

When Installed through npm install react-flagpack --save

  • In a clean create react app (v17) empty flags are shown
  • In a react 16.8 or higher existing app using a flag components crashes the app (quite a big app with webpack which i think actually causes the crash)
  • in a clean create-react-app with react v16.x a blank flag is shown as well (step 4 in steps to reproduce)

Possible Solution

Seems like 1.1.0 was released yesterday, which is not tagged as the current release. It is installed through npm though when no version is specified.

So the easy fix is probably not making the 1.x branches available for now :)

Steps to Reproduce

  1. npx create-react-app my-app
  2. npm i react-flagpack
  3. add jsx <Flag code="NL" gradient="real-linear" size="m" hasDropShadow />
    to the clean app
  4. a empty flag is shown:
    image

Broken NZ/NZL flag

Using this pack through npm provides a New Zealand flag that's broken in different ways in all three sizes. There's a possibility that this applies to several flags, I've only tried the SWE and NZL flags so far.

Please check all that apply

  • visual bug
  • functional bug
  • able to consistently reproduce

Expected Behavior

The flags should be displayed the same way as on your site and in the Figma and Sketch packs where they look fine.

Current Behavior

Errors in the svg-files when used through the react npm pack.

Possible Solution

Sync the svg-files with the ones from the other sources that work to find and fix all flags with incorrect svg's.

Screenshots

Screenshot 2022-08-24 at 14 28 41

Broken on React 18

Dependencies do not allow for React 18 and also require statement is used causing complete failure to compile in a standard create react app setup.

Require isn't defined

installed the package and included it in my NextJS 13 project but the browser threw an error message during runtime with thee following error;
Unhandled Runtime Error
ReferenceError: require is not defined
Call Stack
unknown
node_modules\.pnpm\[email protected][email protected]\node_modules\react-flagpack\dist\react-flag-rollup.cjs.js (1:13)

Broken EU flag

When inputting 'EU' as flag code, page breaks

Please check all that apply

  • visual bug
  • functional bug
  • able to consistently reproduce

Expected Behavior

EU flag should appear

Current Behavior

When inputting 'EU' as flag code, page breaks, regardless of the size

Steps to Reproduce

  1. Set flag code to 'EU'

Screenshots

image

Export Props interface

Hello,
Is there any chance you could export the Props interface so we can use it without hacks?

Thanks

react v18

Hi

Is it safe to force it on react v18 ?

thank you

Building with Webpack fails

  • visual bug
  • functional bug
  • able to consistently reproduce

Awesome project! Thanks for making this available! 🙇‍♂️

Current Behavior

More than a bug report this is a question about the recommended Webpack setup that works with react-flagpack. I checked the docs and couldn't find anything specific about build.

Did I miss something? Is there a recommended setup that should work?

I'm not able to use the library on a custom Webpack project. It's giving the following errors:

WARNING in ./node_modules/react-flagpack/dist/flags/s/894.svg
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /node_modules/react-flagpack/dist/flags/s/894.svg: Unexpected token (3:9)

  1 | var React = require('react');
  2 |
> 3 | function 894 (props) {

I tried to reproduce with CRA but it works fine there.

I also tried to reproduce on Codesandbox with the TS template and I get a different error (see this sandbox)

I'm building with Webpack with the babel-loader, and the following Babel presets:

  • @babel/env
  • @babel/preset-react
  • @babel/preset-typescript

For SVG I have svg-react-loader and svgo-loader.

Your Environment

  • Version used: ^1.0.5
  • Browser Name and version: Not relevant
  • Operating System and version (desktop or mobile): Mac OS 11.4 (Big Sur)
  • Link to your project: It's closed source

Flagpack not loading into NextJS

Please check all that apply

  • functional bug

Current Behavior

Currently the project doesn't work with NextJS. It does work however with a create-react-app.

Possible Solution

  • A possible solution is adding a ESM file to the exports through rollup.
  • Removing the type: "module" from the package.json also stops the project from crashing altogether, however the flag still doesn't render.

Logs

image

Related to issues #46, #45

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.