docs(CLAUDE.md): add code style section aligned with glyphdiff conventions
This commit is contained in:
1
src/shared/config/index.ts
Normal file
1
src/shared/config/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './site';
|
||||
5
src/shared/config/site.ts
Normal file
5
src/shared/config/site.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export const site = {
|
||||
name: 'allmywork',
|
||||
description: 'Portfolio web application',
|
||||
url: 'https://allmywork.localhost'
|
||||
};
|
||||
3
src/shared/index.ts
Normal file
3
src/shared/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './ui';
|
||||
export * from './config';
|
||||
export * from './lib';
|
||||
18
src/shared/lib/api.ts
Normal file
18
src/shared/lib/api.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || '/api';
|
||||
|
||||
export async function fetchApi(endpoint: string, options?: RequestInit) {
|
||||
const url = `${API_BASE}${endpoint}`;
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...options?.headers
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`API error: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
1
src/shared/lib/index.ts
Normal file
1
src/shared/lib/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './api';
|
||||
40
src/shared/ui/Button.svelte
Normal file
40
src/shared/ui/Button.svelte
Normal file
@@ -0,0 +1,40 @@
|
||||
<script lang="ts">
|
||||
interface Props {
|
||||
type?: 'button' | 'submit' | 'reset';
|
||||
variant?: 'primary' | 'secondary' | 'danger';
|
||||
size?: 'sm' | 'md' | 'lg';
|
||||
disabled?: boolean;
|
||||
onclick?: () => void;
|
||||
children: any;
|
||||
}
|
||||
|
||||
let {
|
||||
type = 'button',
|
||||
variant = 'primary',
|
||||
size = 'md',
|
||||
disabled = false,
|
||||
onclick,
|
||||
children
|
||||
}: Props = $props();
|
||||
|
||||
const variants = {
|
||||
primary: 'bg-blue-600 text-white hover:bg-blue-700',
|
||||
secondary: 'bg-gray-200 text-gray-900 hover:bg-gray-300',
|
||||
danger: 'bg-red-600 text-white hover:bg-red-700'
|
||||
};
|
||||
|
||||
const sizes = {
|
||||
sm: 'px-3 py-1.5 text-sm',
|
||||
md: 'px-4 py-2 text-base',
|
||||
lg: 'px-6 py-3 text-lg'
|
||||
};
|
||||
</script>
|
||||
|
||||
<button
|
||||
{type}
|
||||
{disabled}
|
||||
onclick={onclick}
|
||||
class="rounded-md font-medium focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed {variants[variant]} {sizes[size]}"
|
||||
>
|
||||
{@render children()}
|
||||
</button>
|
||||
26
src/shared/ui/Input.svelte
Normal file
26
src/shared/ui/Input.svelte
Normal file
@@ -0,0 +1,26 @@
|
||||
<script lang="ts">
|
||||
interface Props {
|
||||
type?: 'text' | 'email' | 'password' | 'number';
|
||||
placeholder?: string;
|
||||
disabled?: boolean;
|
||||
value?: string;
|
||||
oninput?: (e: Event) => void;
|
||||
}
|
||||
|
||||
let {
|
||||
type = 'text',
|
||||
placeholder = '',
|
||||
disabled = false,
|
||||
value = '',
|
||||
oninput
|
||||
}: Props = $props();
|
||||
</script>
|
||||
|
||||
<input
|
||||
{type}
|
||||
{placeholder}
|
||||
{disabled}
|
||||
{value}
|
||||
oninput={oninput}
|
||||
class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
/>
|
||||
2
src/shared/ui/index.ts
Normal file
2
src/shared/ui/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { default as Button } from './Button.svelte';
|
||||
export { default as Input } from './Input.svelte';
|
||||
Reference in New Issue
Block a user