Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import 'react-flagpack/dist/style.css'
| hasBorder | Boolean | false | true | - |
| hasBorderRadius | Boolean | false | true | - |
| gradient | String | false | '' | 'top-down', 'real-linear' or 'real-circular' |
| basePath | String | false | '' | In case you want to serve your images from a CDN or if you're serving your React application from a custom path. For example with [basePath](https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath) |

## Migrating to 2.0.0
To migrate to react-flagpack 2.0.0 you will need to make some minor changes to your code base. First you will need to add react-flagpack to your post-install hook see [installation](#installation), then run yarn install (ensuring you are on at minimal react-flagpack 2.0.2).
Expand Down
26 changes: 16 additions & 10 deletions src/Flag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { Flags } from 'flagpack-core'
import './Flag.scss'

export interface FlagProps {
code: Flags;
size?: string;
gradient?: '' | 'top-down' | 'real-circular' | 'real-linear';
hasBorder?: boolean;
hasDropShadow?: boolean;
hasBorderRadius?: boolean;
className?: string;
code: Flags
size?: string
gradient?: '' | 'top-down' | 'real-circular' | 'real-linear'
hasBorder?: boolean
hasDropShadow?: boolean
hasBorderRadius?: boolean
className?: string
basePath?: string
}

const Flag: React.FC<FlagProps> = ({
Expand All @@ -20,14 +21,19 @@ const Flag: React.FC<FlagProps> = ({
hasBorder = true,
hasDropShadow = false,
hasBorderRadius = true,
className
className,
basePath = ''
}: FlagProps) => {
return (
<div
className={`flag ${gradient} size-${size} ${hasBorder ? 'border' : ''} ${hasDropShadow ? 'drop-shadow' : ''} ${hasBorderRadius ? 'border-radius' : ''} ${className ? className.replace(/\s\s+/g, ' ').trim() : ''}`}
className={`flag ${gradient} size-${size} ${hasBorder ? 'border' : ''} ${
hasDropShadow ? 'drop-shadow' : ''
} ${hasBorderRadius ? 'border-radius' : ''} ${
className ? className.replace(/\s\s+/g, ' ').trim() : ''
}`}
>
{/* Depend on the build configs to make the assets available at this location */}
<img src={`/flags/${size}/${code}.svg`} />
<img src={`${basePath}/flags/${size}/${code}.svg`} />
</div>
)
}
Expand Down