Create Skill component (#19)

Co-authored-by: hoolek77 <szymon.kin@gmail.com>
This commit is contained in:
Hanna Kozak 2022-10-17 22:32:57 +01:00 committed by GitHub
parent 2a6180a160
commit a8a05c6298
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 82 additions and 7 deletions

13
package-lock.json generated
View file

@ -42,6 +42,7 @@
"prettier": "2.7.1", "prettier": "2.7.1",
"tailwindcss": "3.1.8", "tailwindcss": "3.1.8",
"type-fest": "3.1.0", "type-fest": "3.1.0",
"typescript": "4.8.3",
"vite": "3.1.8", "vite": "3.1.8",
"vite-tsconfig-paths": "3.5.1" "vite-tsconfig-paths": "3.5.1"
}, },
@ -9236,9 +9237,9 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "4.8.2", "version": "4.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
"integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
"dev": true, "dev": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
@ -16782,9 +16783,9 @@
"dev": true "dev": true
}, },
"typescript": { "typescript": {
"version": "4.8.2", "version": "4.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
"integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
"dev": true "dev": true
}, },
"unbox-primitive": { "unbox-primitive": {

View file

@ -15,6 +15,7 @@
"preview": "astro preview", "preview": "astro preview",
"astro": "astro", "astro": "astro",
"lint": "eslint . --ext .cjs,.ts,.tsx,.astro --ignore-path .gitignore", "lint": "eslint . --ext .cjs,.ts,.tsx,.astro --ignore-path .gitignore",
"lint:fix": "eslint . --ext .cjs,.ts,.tsx,.astro --ignore-path .gitignore --fix",
"lint:ts": "tsc --jsx preserve --skipLibCheck" "lint:ts": "tsc --jsx preserve --skipLibCheck"
}, },
"dependencies": { "dependencies": {
@ -51,6 +52,7 @@
"postcss": "8.4.18", "postcss": "8.4.18",
"prettier": "2.7.1", "prettier": "2.7.1",
"tailwindcss": "3.1.8", "tailwindcss": "3.1.8",
"typescript": "4.8.3",
"type-fest": "3.1.0", "type-fest": "3.1.0",
"vite": "3.1.8", "vite": "3.1.8",
"vite-tsconfig-paths": "3.5.1" "vite-tsconfig-paths": "3.5.1"

View file

@ -0,0 +1,21 @@
---
export interface Props extends astroHTML.JSX.HTMLAttributes {
skillLevel: number;
tileLevel: number;
}
const { skillLevel, tileLevel } = Astro.props;
const isFilled = skillLevel >= tileLevel;
---
<div
class:list={[
'w-9',
'h-2',
'last:rounded-l-none',
'last:rounded-r-sm',
'first:rounded-l-sm',
'first:rounded-r-none',
{ 'bg-gray-500': isFilled, 'bg-gray-300': !isFilled },
]}
>
</div>

View file

@ -0,0 +1,14 @@
---
import SkillLevelTile from '@/atoms/skill-level-tile.astro';
export interface Props extends astroHTML.JSX.HTMLAttributes {
skillLevel: number;
}
const { skillLevel } = Astro.props;
const LEVELS = [1, 2, 3, 4, 5];
---
<div class:list={['flex', 'gap-1']}>
{LEVELS.map((tileLevel) => <SkillLevelTile tileLevel={tileLevel} skillLevel={skillLevel} />)}
</div>

View file

@ -0,0 +1,23 @@
---
import Icon from '@/atoms/icon';
import Typography from '@/atoms/typography.astro';
import type { LevelledSkill } from '@/types/skills-section';
import SkillLevel from './skill-level.astro';
export interface Props extends astroHTML.JSX.HTMLAttributes {
levelledSkill: LevelledSkill;
}
const { levelledSkill, ...props } = Astro.props;
---
<div class:list={['flex', 'flex-col', 'gap-2']} {...props}>
<div class:list={['flex', 'gap-2', 'h-5']}>
<a href={levelledSkill.url} target="_blank" rel="noopener noreferrer">
<Icon client:load name={levelledSkill.icon} color={levelledSkill.iconColor} size={20} />
</a>
<Typography variant="tile-subtitle" class="text-gray-700">{levelledSkill.name}</Typography>
</div>
<SkillLevel skillLevel={levelledSkill.level} />
</div>

View file

@ -0,0 +1,14 @@
---
import Skill from '@/organisms/skill.astro';
import type { LevelledSkill } from '@/types/skills-section';
const levelledSkill: LevelledSkill = {
icon: 'simple-icons:react',
iconColor: '#61DAFB',
name: 'React.js',
level: 3,
url: 'https://reactjs.org/',
};
---
<Skill levelledSkill={levelledSkill} />

View file

@ -1,6 +1,6 @@
import type { SectionConfig, Tag } from './common'; import type { SectionConfig, Tag } from './common';
interface LevelledSkill extends Tag { export interface LevelledSkill extends Tag {
level: 1 | 2 | 3 | 4 | 5; level: 1 | 2 | 3 | 4 | 5;
} }