PYPI Version Badge - Svelte Shields
Props #
- packageName
- pypiBaseUrl
- style
- logo
- logoColor
- logoSize
- label
- labelColor
- color
- cacheSeconds
- link
- class: classname
- ...attributes
Types #
import type { HTMLImgAttributes } from 'svelte/elements';
export type LinkType = string[] | [string, string];
export interface BaseBadgePropsType {
style?: 'flat' | 'flat-square' | 'for-the-badge' | 'plastic' | 'social';
logo?: string | undefined | null;
logoColor?: string | undefined | null;
logoSize?: string | undefined | null;
label?: string | undefined | null;
labelColor?: string | undefined | null;
color?: string | undefined | null;
cacheSeconds?: string | undefined | null;
link?: LinkType;
class?: string | undefined | null;
}
interface ExtendedStyle extends BaseBadgePropsType, HTMLImgAttributes {
style?: 'flat' | 'flat-square' | 'for-the-badge' | 'plastic' | 'social';
}
export interface PypiVersionPropsType extends ExtendedStyle {
packageName: string;
pypiBaseUrl?: string;
}
Examples #
Basic usage #
packageName
may be the name of an unscoped package like package-name
or a
scoped package like @author/package-name
.
tag
can be next, v1, v2, beta
, etc.
<script lang="ts">
import { PypiVersion, type PypiVersionPropsType } from 'svelte-shields';
const basic: PypiVersionPropsType = {
packageName: 'vennfig'
};
</script>
<PypiVersion {...basic} />
Style #
Possible values: flat, flat-square, plastic, for-the-badge, social. If not specified, the default style for this badge is "flat".
<script lang="ts">
import { PypiVersion, type PypiVersionPropsType } from 'svelte-shields';
const style1: PypiVersionPropsType = {
packageName: 'vennfig',
style: 'flat'
};
const style2: PypiVersionPropsType = {
packageName: 'vennfig',
style: 'flat-square'
};
const style3: PypiVersionPropsType = {
packageName: 'vennfig',
style: 'for-the-badge'
};
const style4: PypiVersionPropsType = {
packageName: 'vennfig',
style: 'plastic'
};
const style5: PypiVersionPropsType = {
packageName: 'vennfig',
style: 'social'
};
</script>
<div class="grid gap-4">
<PypiVersion {...style1} />
<PypiVersion {...style2} />
<PypiVersion {...style3} />
<PypiVersion {...style4} />
<PypiVersion {...style5} />
</div>
Color #
Background color of the right part (hex, rgb, rgba, hsl, hsla and css named colors supported).
<script lang="ts">
import { PypiVersion, type PypiVersionPropsType } from 'svelte-shields';
const color1: PypiVersionPropsType = {
packageName: 'vennfig',
color: 'green'
};
const color2: PypiVersionPropsType = {
packageName: 'vennfig',
color: '00FF00'
};
const color3: PypiVersionPropsType = {
packageName: 'vennfig',
color: 'rgb(0, 255, 0)'
};
const color4: PypiVersionPropsType = {
packageName: 'vennfig',
color: 'rgba(0, 255, 0, 1)'
};
const color5: PypiVersionPropsType = {
packageName: 'vennfig',
color: 'hsl(120, 100%, 50%)'
};
const color6: PypiVersionPropsType = {
packageName: 'vennfig',
color: 'hsla(120, 100%, 50%, 1)'
};
</script>
<div class="grid gap-4">
<PypiVersion {...color1} />
<PypiVersion {...color2} />
<PypiVersion {...color3} />
<PypiVersion {...color4} />
<PypiVersion {...color5} />
<PypiVersion {...color6} />
</div>
Logo & Label #
<script lang="ts">
import { PypiVersion, type PypiVersionPropsType } from 'svelte-shields';
const logo_label: PypiVersionPropsType = {
packageName: 'vennfig',
logo: 'python',
label: 'VENNFIG'
};
</script>
<PypiVersion {...logo_label} />
Link #
Specify what clicking on the left/right of a badge should do.
<script lang="ts">
import { PypiVersion, type PypiVersionPropsType } from 'svelte-shields';
const link: PypiVersionPropsType = {
packageName: 'vennfig',
label: 'VENNFIG',
link: ['https://vennfig.codewithshin.com', 'https://github.com/shinokada/vennfig']
};
</script>
<PypiVersion {...link} />
Other #
cacheSeconds
is HTTP cache lifetime (rules are applied to infer a default value on a per-badge
basis, any values specified below the default will be ignored).
<script lang="ts">
import { PypiVersion, type PypiVersionPropsType } from 'svelte-shields';
const other: PypiVersionPropsType = {
packageName: 'vennfig',
cacheSeconds: '86400'
};
</script>
<PypiVersion {...other} />