Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Nov 13, 2024
1 parent 10172c7 commit 54aa8e2
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 10 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build
on:
push:
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v4

- name: Cache node modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Run tests & linter
run: |
npm ci
npm run lint
npm run test
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
8 changes: 6 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"useTabs": true,
"singleQuote": true,
"tabWidth": 2,
"semi": false,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"plugins": [
"prettier-plugin-svelte"
],
"overrides": [
{
"files": "*.svelte",
Expand All @@ -12,4 +16,4 @@
}
}
]
}
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.formatOnSave": true,
"editor.tabSize": 2,
}
2 changes: 1 addition & 1 deletion src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ declare global {
}
}

export {};
export { }
7 changes: 6 additions & 1 deletion src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<link rel="icon" href="%sveltekit.assets%/favicon.ico" />

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Geist+Mono:[email protected]&display=swap" rel="stylesheet">

<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
Expand Down
8 changes: 4 additions & 4 deletions src/demo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest';
import { describe, it, expect } from 'vitest'

describe('sum test', () => {
it('adds 1 + 2 to equal 3', () => {
expect(1 + 2).toBe(3);
});
});
expect(1 + 2).toBe(3)
})
})
28 changes: 26 additions & 2 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p>
<script lang='ts'>
import './styles.css';
const LONGITUD_MAXIMA = 140
const claseEspacioRestante = (restantes: number): string =>
restantes > 10 ? 'ok' : (restantes > 5 ? 'limite' : 'pasado')
let tweet = $state('')
let restantes = $derived(LONGITUD_MAXIMA - tweet.length)
let espacioRestanteClass = $derived(claseEspacioRestante(restantes))
</script>

<article class="container">
<h1>Twitter - Svelte</h1>
<form name="form" class="form">
<div>
<textarea id="texto" name="texto" data-testid="texto" placeholder="¿Qué estás pensando?" bind:value={tweet}></textarea>
</div>
<div>
<span data-testid="restantes" class="badge {espacioRestanteClass}">
{restantes}
</span>
</div>
</form>
</article>
44 changes: 44 additions & 0 deletions src/routes/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
* {
font-family: "Geist Mono", sans-serif;
box-sizing: border-box;
}

form {
display: flex;
flex-direction: column;
font-size: 1.5rem;
}

h1 {
font-size: 1.7rem;
}

input,
textarea {
width: 100%;
height: 10em;
font-size: 1em;
margin-bottom: 2em;
padding: 0.8em;
border: 1px solid darkslategray;
}

.badge {
font-size: 1.2em;
padding: 1em;
border-radius: 35%;
}

.pasado {
color: white;
background-color: rgb(201, 72, 72);
}

.limite {
background-color: rgb(203, 203, 31);
}

.ok {
color: white;
background-color: green;
}
Binary file added static/favicon.ico
Binary file not shown.
Binary file removed static/favicon.png
Binary file not shown.

0 comments on commit 54aa8e2

Please sign in to comment.