free-astro-components 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.mjs +8 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +11 -0
- package/README.md +1 -0
- package/astro.config.mjs +8 -0
- package/package.json +34 -0
- package/public/favicon.svg +9 -0
- package/src/components/Button.astro +93 -0
- package/src/components/Icon.astro +19 -0
- package/src/css/main.css +16 -0
- package/src/data/icons.ts +10 -0
- package/src/env.d.ts +1 -0
- package/src/index.js +2 -0
- package/src/layouts/Layout.astro +24 -0
- package/src/pages/index.astro +131 -0
- package/src/types/index.d.ts +5 -0
- package/tailwind.config.mjs +60 -0
- package/tsconfig.json +3 -0
package/.prettierrc.mjs
ADDED
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Free Astro Components
|
package/astro.config.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "free-astro-components",
|
|
3
|
+
"description": "A collection of free Astro components",
|
|
4
|
+
"author": "Denis Ventura",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"version": "0.0.1",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": {
|
|
10
|
+
"types": "./src/types/index.d.ts",
|
|
11
|
+
"default": "./src/index.js"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"main": "./src/index.js",
|
|
16
|
+
"types": "./src/types/index.d.ts",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "astro dev",
|
|
19
|
+
"start": "astro dev",
|
|
20
|
+
"build": "astro check && astro build",
|
|
21
|
+
"preview": "astro preview",
|
|
22
|
+
"astro": "astro"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@astrojs/check": "^0.8.2",
|
|
26
|
+
"@astrojs/tailwind": "^5.1.0",
|
|
27
|
+
"astro": "^4.12.2",
|
|
28
|
+
"tailwindcss": "^3.4.6",
|
|
29
|
+
"typescript": "^5.5.3"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"prettier": "^3.3.3"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 128 128">
|
|
2
|
+
<path d="M50.4 78.5a75.1 75.1 0 0 0-28.5 6.9l24.2-65.7c.7-2 1.9-3.2 3.4-3.2h29c1.5 0 2.7 1.2 3.4 3.2l24.2 65.7s-11.6-7-28.5-7L67 45.5c-.4-1.7-1.6-2.8-2.9-2.8-1.3 0-2.5 1.1-2.9 2.7L50.4 78.5Zm-1.1 28.2Zm-4.2-20.2c-2 6.6-.6 15.8 4.2 20.2a17.5 17.5 0 0 1 .2-.7 5.5 5.5 0 0 1 5.7-4.5c2.8.1 4.3 1.5 4.7 4.7.2 1.1.2 2.3.2 3.5v.4c0 2.7.7 5.2 2.2 7.4a13 13 0 0 0 5.7 4.9v-.3l-.2-.3c-1.8-5.6-.5-9.5 4.4-12.8l1.5-1a73 73 0 0 0 3.2-2.2 16 16 0 0 0 6.8-11.4c.3-2 .1-4-.6-6l-.8.6-1.6 1a37 37 0 0 1-22.4 2.7c-5-.7-9.7-2-13.2-6.2Z" />
|
|
3
|
+
<style>
|
|
4
|
+
path { fill: #000; }
|
|
5
|
+
@media (prefers-color-scheme: dark) {
|
|
6
|
+
path { fill: #FFF; }
|
|
7
|
+
}
|
|
8
|
+
</style>
|
|
9
|
+
</svg>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Icon from './Icon.astro'
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
href?: string
|
|
6
|
+
icon?: string
|
|
7
|
+
label?: string
|
|
8
|
+
type?:
|
|
9
|
+
| 'primary'
|
|
10
|
+
| 'primary-outline'
|
|
11
|
+
| 'secondary'
|
|
12
|
+
| 'secondary-outline'
|
|
13
|
+
| 'tertiary'
|
|
14
|
+
| 'tertiary-outline'
|
|
15
|
+
iconPosition?: 'left' | 'right'
|
|
16
|
+
size?: 'small' | 'medium' | 'large'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
href,
|
|
21
|
+
icon,
|
|
22
|
+
label,
|
|
23
|
+
type = 'primary',
|
|
24
|
+
iconPosition = 'right',
|
|
25
|
+
size = 'medium',
|
|
26
|
+
...props
|
|
27
|
+
} = Astro.props
|
|
28
|
+
|
|
29
|
+
const typeClasses = {
|
|
30
|
+
primary:
|
|
31
|
+
'bg-primary-300 border-primary-300 text-white shadow-primary-400/15 hover:bg-primary-200 hover:border-primary-200 active:bg-primary-400 active:border-primary-400 hover:shadow-primary-400/15 active:shadow-primary-400/15',
|
|
32
|
+
'primary-outline':
|
|
33
|
+
'bg-white border-primary-300 text-primary-300 shadow-primary-400/15 hover:border-primary-200 hover:text-primary-200 active:border-primary-400 active:text-primary-400 hover:shadow-primary-400/15 active:shadow-primary-400/15',
|
|
34
|
+
secondary:
|
|
35
|
+
'bg-secondary-300 border-secondary-300 text-white shadow-secondary-400/15 hover:bg-secondary-200 hover:border-secondary-200 active:bg-secondary-400 active:border-secondary-400 hover:shadow-secondary-400/15 active:shadow-secondary-400/15',
|
|
36
|
+
'secondary-outline':
|
|
37
|
+
'bg-white border-secondary-300 text-secondary-300 shadow-secondary-400/15 hover:border-secondary-200 hover:text-secondary-200 active:border-secondary-400 active:text-secondary-400 hover:shadow-secondary-400/15 active:shadow-secondary-400/15',
|
|
38
|
+
tertiary:
|
|
39
|
+
'bg-tertiary-300 border-tertiary-300 text-white shadow-tertiary-400/15 hover:bg-tertiary-200 hover:border-tertiary-200 active:bg-tertiary-400 active:border-tertiary-400 hover:shadow-tertiary-400/15 active:shadow-tertiary-400/15',
|
|
40
|
+
'tertiary-outline':
|
|
41
|
+
'bg-white border-tertiary-300 text-tertiary-300 shadow-tertiary-400/15 hover:border-tertiary-200 hover:text-tertiary-200 active:border-tertiary-400 active:text-tertiary-400 hover:shadow-tertiary-400/15 active:shadow-tertiary-400/15',
|
|
42
|
+
}[type]
|
|
43
|
+
|
|
44
|
+
const sizeClasses = {
|
|
45
|
+
small: 'text-xs px-4 h-8',
|
|
46
|
+
medium: 'text-sm px-6 h-10',
|
|
47
|
+
large: 'text-sm px-8 h-12',
|
|
48
|
+
}[size]
|
|
49
|
+
|
|
50
|
+
const onlyIconClasses = {
|
|
51
|
+
small: 'w-8 h-8',
|
|
52
|
+
medium: 'w-10 h-10',
|
|
53
|
+
large: 'w-12 h-12',
|
|
54
|
+
}[size]
|
|
55
|
+
|
|
56
|
+
const buttonClasses = [
|
|
57
|
+
'inline-flex justify-center items-center gap-2 text-sm font-bold border shadow-md rounded-lg transition duration-300 ease-in-out hover:shadow-lg active:shadow-md',
|
|
58
|
+
typeClasses,
|
|
59
|
+
label ? sizeClasses : onlyIconClasses,
|
|
60
|
+
]
|
|
61
|
+
.filter(Boolean)
|
|
62
|
+
.join(' ')
|
|
63
|
+
|
|
64
|
+
const iconClasses = {
|
|
65
|
+
small: 'w-5 h-5',
|
|
66
|
+
medium: 'w-6 h-6',
|
|
67
|
+
large: 'w-6 h-6',
|
|
68
|
+
}[size]
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
{
|
|
72
|
+
href ? (
|
|
73
|
+
<a class={buttonClasses} href={href} {...props}>
|
|
74
|
+
{icon && iconPosition === 'left' && (
|
|
75
|
+
<Icon icon={icon} class={iconClasses} />
|
|
76
|
+
)}
|
|
77
|
+
{label && <span>{label}</span>}
|
|
78
|
+
{icon && iconPosition === 'right' && (
|
|
79
|
+
<Icon icon={icon} class={iconClasses} />
|
|
80
|
+
)}
|
|
81
|
+
</a>
|
|
82
|
+
) : (
|
|
83
|
+
<button class={buttonClasses} {...props}>
|
|
84
|
+
{icon && iconPosition === 'left' && (
|
|
85
|
+
<Icon icon={icon} class={iconClasses} />
|
|
86
|
+
)}
|
|
87
|
+
{label && <span>{label}</span>}
|
|
88
|
+
{icon && iconPosition === 'right' && (
|
|
89
|
+
<Icon icon={icon} class={iconClasses} />
|
|
90
|
+
)}
|
|
91
|
+
</button>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { icons } from '../data/icons.ts'
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
icon: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { icon, ...props } = Astro.props
|
|
9
|
+
const iconPath = icons.find((i) => i.name === icon)?.path
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<svg
|
|
13
|
+
fill="none"
|
|
14
|
+
viewBox="0 0 24 24"
|
|
15
|
+
stroke-width="1.5"
|
|
16
|
+
stroke="currentColor"
|
|
17
|
+
set:html={iconPath}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
package/src/css/main.css
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const icons = [
|
|
2
|
+
{
|
|
3
|
+
name: 'academic-cap',
|
|
4
|
+
path: '<path stroke-linecap="round" stroke-linejoin="round" d="M4.26 10.147a60.438 60.438 0 0 0-.491 6.347A48.62 48.62 0 0 1 12 20.904a48.62 48.62 0 0 1 8.232-4.41 60.46 60.46 0 0 0-.491-6.347m-15.482 0a50.636 50.636 0 0 0-2.658-.813A59.906 59.906 0 0 1 12 3.493a59.903 59.903 0 0 1 10.399 5.84c-.896.248-1.783.52-2.658.814m-15.482 0A50.717 50.717 0 0 1 12 13.489a50.702 50.702 0 0 1 7.74-3.342M6.75 15a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm0 0v-3.675A55.378 55.378 0 0 1 12 8.443m-7.007 11.55A5.981 5.981 0 0 0 6.75 15.75v-1.5" />'
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
name: 'arrow-right',
|
|
8
|
+
path: '<path stroke-linecap="round" stroke-linejoin="round" d="M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3" />'
|
|
9
|
+
}
|
|
10
|
+
]
|
package/src/env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="astro/client" />
|
package/src/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
import '../css/main.css'
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
title: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { title } = Astro.props
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<!doctype html>
|
|
12
|
+
<html lang="en">
|
|
13
|
+
<head>
|
|
14
|
+
<meta charset="UTF-8" />
|
|
15
|
+
<meta name="description" content="Astro description" />
|
|
16
|
+
<meta name="viewport" content="width=device-width" />
|
|
17
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
18
|
+
<meta name="generator" content={Astro.generator} />
|
|
19
|
+
<title>{title}</title>
|
|
20
|
+
</head>
|
|
21
|
+
<body>
|
|
22
|
+
<slot />
|
|
23
|
+
</body>
|
|
24
|
+
</html>
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Layout from '../layouts/Layout.astro'
|
|
3
|
+
import Button from '../components/Button.astro'
|
|
4
|
+
---
|
|
5
|
+
<Layout title="Welcome to Astro.">
|
|
6
|
+
<main class="p-16">
|
|
7
|
+
<h1 class="text-3xl">Components</h1>
|
|
8
|
+
|
|
9
|
+
<div class="flex flex-col gap-4">
|
|
10
|
+
<h2 class="text-2xl">Buttons</h2>
|
|
11
|
+
<p>Primary buttons</p>
|
|
12
|
+
<div class="flex flex-wrap gap-4">
|
|
13
|
+
<Button size="small" icon="arrow-right" label="Primary Button" />
|
|
14
|
+
<Button icon="arrow-right" label="Primary Button" />
|
|
15
|
+
<Button size="large" icon="arrow-right" label="Primary Button" />
|
|
16
|
+
<Button size="small" icon="arrow-right" />
|
|
17
|
+
<Button icon="arrow-right" />
|
|
18
|
+
<Button size="large" icon="arrow-right" />
|
|
19
|
+
</div>
|
|
20
|
+
<p>Primary outline buttons</p>
|
|
21
|
+
<div class="flex flex-wrap gap-4">
|
|
22
|
+
<Button
|
|
23
|
+
type="primary-outline"
|
|
24
|
+
size="small"
|
|
25
|
+
icon="arrow-right"
|
|
26
|
+
label="Primary Button"
|
|
27
|
+
/>
|
|
28
|
+
<Button
|
|
29
|
+
type="primary-outline"
|
|
30
|
+
icon="arrow-right"
|
|
31
|
+
label="Primary Button"
|
|
32
|
+
/>
|
|
33
|
+
<Button
|
|
34
|
+
type="primary-outline"
|
|
35
|
+
size="large"
|
|
36
|
+
icon="arrow-right"
|
|
37
|
+
label="Primary Button"
|
|
38
|
+
/>
|
|
39
|
+
|
|
40
|
+
<Button type="primary-outline" size="small" icon="arrow-right" />
|
|
41
|
+
<Button type="primary-outline" icon="arrow-right" />
|
|
42
|
+
<Button type="primary-outline" size="large" icon="arrow-right" />
|
|
43
|
+
</div>
|
|
44
|
+
<p>Secondary buttons</p>
|
|
45
|
+
|
|
46
|
+
<div class="flex flex-wrap gap-4">
|
|
47
|
+
<Button
|
|
48
|
+
type="secondary"
|
|
49
|
+
size="small"
|
|
50
|
+
icon="arrow-right"
|
|
51
|
+
label="Secondary Button"
|
|
52
|
+
/>
|
|
53
|
+
<Button type="secondary" icon="arrow-right" label="Secondary Button" />
|
|
54
|
+
<Button
|
|
55
|
+
type="secondary"
|
|
56
|
+
size="large"
|
|
57
|
+
icon="arrow-right"
|
|
58
|
+
label="Secondary Button"
|
|
59
|
+
/>
|
|
60
|
+
<Button type="secondary" size="small" icon="arrow-right" />
|
|
61
|
+
<Button type="secondary" icon="arrow-right" />
|
|
62
|
+
<Button type="secondary" size="large" icon="arrow-right" />
|
|
63
|
+
</div>
|
|
64
|
+
<p>Secondary outline buttons</p>
|
|
65
|
+
<div class="flex flex-wrap gap-4">
|
|
66
|
+
<Button
|
|
67
|
+
type="secondary-outline"
|
|
68
|
+
size="small"
|
|
69
|
+
icon="arrow-right"
|
|
70
|
+
label="Secondary Button"
|
|
71
|
+
/>
|
|
72
|
+
<Button
|
|
73
|
+
type="secondary-outline"
|
|
74
|
+
icon="arrow-right"
|
|
75
|
+
label="Secondary Button"
|
|
76
|
+
/>
|
|
77
|
+
<Button
|
|
78
|
+
type="secondary-outline"
|
|
79
|
+
size="large"
|
|
80
|
+
icon="arrow-right"
|
|
81
|
+
label="Secondary Button"
|
|
82
|
+
/>
|
|
83
|
+
<Button type="secondary-outline" size="small" icon="arrow-right" />
|
|
84
|
+
<Button type="secondary-outline" icon="arrow-right" />
|
|
85
|
+
<Button type="secondary-outline" size="large" icon="arrow-right" />
|
|
86
|
+
</div>
|
|
87
|
+
<p>Tertiary buttons</p>
|
|
88
|
+
<div class="flex flex-wrap gap-4">
|
|
89
|
+
<Button
|
|
90
|
+
type="tertiary"
|
|
91
|
+
size="small"
|
|
92
|
+
icon="arrow-right"
|
|
93
|
+
label="Tertiary Button"
|
|
94
|
+
/>
|
|
95
|
+
<Button type="tertiary" icon="arrow-right" label="Tertiary Button" />
|
|
96
|
+
<Button
|
|
97
|
+
type="tertiary"
|
|
98
|
+
size="large"
|
|
99
|
+
icon="arrow-right"
|
|
100
|
+
label="Tertiary Button"
|
|
101
|
+
/>
|
|
102
|
+
<Button type="tertiary" size="small" icon="arrow-right" />
|
|
103
|
+
<Button type="tertiary" icon="arrow-right" />
|
|
104
|
+
<Button type="tertiary" size="large" icon="arrow-right" />
|
|
105
|
+
</div>
|
|
106
|
+
<p>Tertiary outline buttons</p>
|
|
107
|
+
<div class="flex flex-wrap gap-4">
|
|
108
|
+
<Button
|
|
109
|
+
type="tertiary-outline"
|
|
110
|
+
size="small"
|
|
111
|
+
icon="arrow-right"
|
|
112
|
+
label="Tertiary Button"
|
|
113
|
+
/>
|
|
114
|
+
<Button
|
|
115
|
+
type="tertiary-outline"
|
|
116
|
+
icon="arrow-right"
|
|
117
|
+
label="Tertiary Button"
|
|
118
|
+
/>
|
|
119
|
+
<Button
|
|
120
|
+
type="tertiary-outline"
|
|
121
|
+
size="large"
|
|
122
|
+
icon="arrow-right"
|
|
123
|
+
label="Tertiary Button"
|
|
124
|
+
/>
|
|
125
|
+
<Button type="tertiary-outline" size="small" icon="arrow-right" />
|
|
126
|
+
<Button type="tertiary-outline" icon="arrow-right" />
|
|
127
|
+
<Button type="tertiary-outline" size="large" icon="arrow-right" />
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
</main>
|
|
131
|
+
</Layout>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
export default {
|
|
3
|
+
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
|
|
4
|
+
theme: {
|
|
5
|
+
colors: {
|
|
6
|
+
transparent: 'transparent',
|
|
7
|
+
current: 'currentColor',
|
|
8
|
+
white: '#FFFFFF',
|
|
9
|
+
primary: {
|
|
10
|
+
100: '#73C5FF',
|
|
11
|
+
200: '#3EACFA',
|
|
12
|
+
300: '#0E91EF',
|
|
13
|
+
400: '#0B83D9',
|
|
14
|
+
},
|
|
15
|
+
secondary: {
|
|
16
|
+
100: '#5865BA',
|
|
17
|
+
200: '#263699',
|
|
18
|
+
300: '#000F73',
|
|
19
|
+
400: '#000C58',
|
|
20
|
+
},
|
|
21
|
+
tertiary: {
|
|
22
|
+
100: '#FFA96A',
|
|
23
|
+
200: '#FF9040',
|
|
24
|
+
300: '#FF661A',
|
|
25
|
+
400: '#F26C0C',
|
|
26
|
+
},
|
|
27
|
+
neutral: {
|
|
28
|
+
100: '#F7F8FA',
|
|
29
|
+
200: '#E1E2E6',
|
|
30
|
+
300: '#98A1B3',
|
|
31
|
+
400: '#666E80',
|
|
32
|
+
500: '#17181A',
|
|
33
|
+
},
|
|
34
|
+
success: {
|
|
35
|
+
100: '#9CF0BD',
|
|
36
|
+
200: '#07D95A',
|
|
37
|
+
},
|
|
38
|
+
error: {
|
|
39
|
+
100: '#FCA3B2',
|
|
40
|
+
200: '#F8183E',
|
|
41
|
+
},
|
|
42
|
+
warning: {
|
|
43
|
+
100: '#FFD06E',
|
|
44
|
+
200: '#FFB800',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
fontSize: {
|
|
48
|
+
xxs: '0.75rem',
|
|
49
|
+
xs: '0.813rem',
|
|
50
|
+
sm: '0.875rem',
|
|
51
|
+
base: '1rem',
|
|
52
|
+
lg: '1.125rem',
|
|
53
|
+
xl: '1.25rem',
|
|
54
|
+
'2xl': '1.5rem',
|
|
55
|
+
'3xl': '2rem',
|
|
56
|
+
},
|
|
57
|
+
extend: {},
|
|
58
|
+
},
|
|
59
|
+
plugins: [],
|
|
60
|
+
}
|
package/tsconfig.json
ADDED