Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…dchickens into hanya/postmatch
  • Loading branch information
azaleacolburn committed Nov 19, 2024
2 parents bc89d75 + 938b296 commit 45e3230
Show file tree
Hide file tree
Showing 17 changed files with 496 additions and 153 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
22 changes: 22 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Format

on:
push:
pull_request:

jobs:
format:
runs-on: ubuntu-latest
name: Format Files
steps:
- uses: actions/checkout@v3
- uses: oven-sh/setup-bun@v2
- run: bun install
- name: Prettier
run: bun run format ./src
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
- uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
with:
commit_message: 'style: format files'
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# inflatedchickens

## usage

```bash
# install dependencies
bun i
Expand Down
Binary file modified bun.lockb
Binary file not shown.
68 changes: 32 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
{
"name": "floatingchickens",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.3.1",
"@sveltejs/kit": "^2.7.3",
"@typescript-eslint/eslint-plugin": "^8.12.2",
"@typescript-eslint/parser": "^8.12.2",
"autoprefixer": "^10.4.20",
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.46.0",
"postcss": "^8.4.47",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.7",
"svelte": "^5.1.6",
"svelte-check": "^4.0.5",
"tailwindcss": "^3.4.14",
"tslib": "^2.8.0",
"typescript": "^5.6.3",
"vite": "^5.4.10"
},
"type": "module",
"dependencies": {
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"svelte-kit": "^1.2.0"
}
"name": "inflatedchickens",
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"format": "prettier --write .",
"lint": "prettier --check . && eslint ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.3.1",
"@sveltejs/kit": "^2.8.1",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@types/eslint": "^9.6.1",
"autoprefixer": "^10.4.20",
"eslint": "^9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.46.0",
"globals": "^15.12.0",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.8",
"prettier-plugin-tailwindcss": "^0.6.8",
"svelte": "^5.1.16",
"svelte-check": "^4.0.7",
"tailwindcss": "^3.4.14",
"typescript": "^5.6.3",
"typescript-eslint": "^8.14.0",
"vite": "^5.4.11"
}
}
10 changes: 5 additions & 5 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};
20 changes: 10 additions & 10 deletions src/app.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="flamingChicken.png" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
<head>
<meta charset="utf-8" />
<link rel="icon" href="flamingChicken.png" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
24 changes: 19 additions & 5 deletions src/lib/components/Action.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
<script lang="ts">
import type { ActionData } from '$lib/types';
import type { AutoActionData } from '$lib/types';
let { action = $bindable(), deleteself }: { action: ActionData; deleteself: () => void } = $props()
let {
action_data = $bindable(),
deleteself
}: { action_data: AutoActionData; deleteself: () => void } = $props();
let actionBorderColor = $derived(action.result === 'success' ? 'border-cresc_green' : 'border-fail_red');
//let actionBorderColor = $derived(action.success ? 'border-cresc_green' : 'border-fail_red');
let actionBackgroundColor = $derived(action_data.success ? 'bg-cresc_green' : 'bg-fail_red');
</script>

<button class="{actionBorderColor} w-full p-1 rounded border-2 text-text_yellow" onclick={deleteself}>
{action.type}
<!-- <button -->
<!-- class="{actionBorderColor} w-full p-1 rounded border-2 text-text_yellow" -->
<!-- onclick={deleteself} -->
<!-- > -->
<!-- {action.type} -->
<!-- </button> -->

<button
class="{actionBackgroundColor} w-full p-1 rounded border-2 border-outline_gray text-text_white"
onclick={deleteself}
>
{action_data.action}
</button>
21 changes: 21 additions & 0 deletions src/lib/components/SuccessFail.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script lang="ts">
let { complete, cancel }: { complete: (success: boolean) => void; cancel: () => void } =
$props();
</script>

<div
class="bg-zinc-800 text-zinc-50 text-xl font-extrabold fixed inset-0 grid grid-cols-2 grid-rows-3 gap-4 p-4"
>
<button
class="rounded-lg row-span-2 shadow-lg shadow-green-600/50 bg-green-600"
onclick={() => complete(true)}>Success</button
>
<button
class="rounded-lg row-span-2 shadow-lg shadow-red-600/50 bg-red-600"
onclick={() => complete(false)}>Fail</button
>
<button
class="rounded-lg col-span-2 shadow-lg shadow-zinc-600/50 bg-zinc-600"
onclick={() => cancel()}>Cancel</button
>
</div>
25 changes: 12 additions & 13 deletions src/lib/components/Timeline.svelte
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<script lang="ts">
import type { ActionData } from '$lib/types';
import type { AutoActionData } from '$lib/types';
import Action from './Action.svelte';
let { actions = $bindable() }: { actions: ActionData[] } = $props()
let { actions = $bindable() }: { actions: AutoActionData[] } = $props();
// let latestActions: AutoActionData[] = $derived(actions.toReversed().slice(0, 5));
</script>
<h1 class="text-text_red">Timeline</h1>
<div class="flex flex-col items-center h-full bg-btn_grey border-solid border-2 border-text_red p-2 rounded gap-2 w-full overflow-auto">
{#each actions as _, i}
<Action
bind:action={actions[i]}
deleteself={() => {
actions.splice(i, 1);
}}
/>
{/each}
</div>

{#each actions as _, i}
<Action
action_data={actions[i]}
deleteself={() => {
actions.splice(actions.indexOf(actions[i]), 1);
}}
/>
{/each}
114 changes: 95 additions & 19 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,95 @@
export enum actionType {
IntakeTote = 'Intake Tote',
EjectTote = 'Eject Tote',
IntakeBalloon = 'Intake Balloon',
ScoreLow = 'Score Low',
ScoreExternalTote = 'Score External Tote',
ScoreInternalTote = 'Score Internal Tote',
ScoreAnotherRobotsTote = 'Score Another Robots Tote'
}

export enum actionResult {
success = 'success',
fail = 'fail'
}

export type ActionData = {
type: actionType;
result: actionResult;
}
// For DB
export type Match = {
match_key: string;
event_key: string;
};

export type User = {
id: string;
name: string;
is_admin: boolean;
slack_token: string;
};

/// Counts
export type AutoActionsTM = ActionsTM & {
bunny_intake_success: number;
bunny_intake_failure: number;
bunny_tote_success: number;
bunny_tote_failure: number;
bunny_low_success: number;
bunny_low_failure: number;
actions: AutoActionData[];
};

export type TeleActionsTM = ActionsTM & {
actions: TeleActionData[];
};

export type ActionsTM = {
id: number;
tote_intake_success: number;
tote_intake_failure: number;
tote_eject_success: number;
tote_eject_failure: number;
balloon_intake_success: number;
bollon_intake_failure: number;
score_low_success: number;
score_low_failure: number;
score_internal_success: number;
score_internal_failure: number;
score_external_success: number;
score_external_failure: number;
score_other_robot_success: number;
score_other_robot_failure: number;
};

export type TeamMatch = {
id: number;
scout_id: string;
match_key: string;
team_key: string;
skill: number;
notes: string;
broke: boolean;
died: boolean;
auto_actions: AutoActionData[];
tele_actions: TeleActionData[];
};

export type AutoActionData = {
action: AutoAction;
success: boolean;
};

export type TeleActionData = {
action: TeleAction;
success: boolean;
};

// Action Types
// Naming Convention: action_type + game_piece + where
export type TeleAction =
| 'IntakeTote'
| 'IntakeBalloon'
| 'IntakeBalloonCoral'
| 'ScoreBalloonInternalTote' // Held by scorer
| 'ScoreBalloonExternalTote' // Held by alliance member
| 'ScoreBalloonUncontrolledTote'
| 'ScoreBalloonLow'
| 'EjectBalloon'
| 'EjectBunny' // Could happen in Tele; we could instead move this to BunnyAction and reset held_bunnies to 0 after Auto
| 'EjectTote';

export type BunnyAction =
| 'IntakeBunny'
| 'ScoreBunnyInternalTote'
| 'ScoreBunnyExternalTote'
| 'ScoreBunnyUncontrolledTote'
| 'ScoreBunnyLow';
export type AutoAction = TeleAction | BunnyAction;

// For state machine
export type ItemInputState = 'Intake' | 'Score' | 'Eject' | 'None';
export type TeleInputState = TeleAction | ItemInputState;
export type AutoInputState = TeleInputState | BunnyAction;
8 changes: 4 additions & 4 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script>
let { children } = $props();
import "../app.css";
import '../app.css';
</script>

{@render children()}

<style lang="postcss">
:global(body) {
@apply bg-bg_gray;
@apply bg-zinc-800;
}
</style>

{@render children()}
Loading

0 comments on commit 45e3230

Please sign in to comment.