Skip to content

Commit

Permalink
initial grid setup
Browse files Browse the repository at this point in the history
  • Loading branch information
kajgm committed Jun 2, 2024
1 parent 9365cc6 commit 33c589b
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const subscribeMessage = {
};
function websocketConnect() {
status.value = 'connecting';
const socket = new WebSocket('wss://ws-feed.exchange.coinbase.com');
socket.onopen = () => {
Expand Down
103 changes: 103 additions & 0 deletions src/views/Grid.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { type Status, type TickerType } from '@/types/types';
const props = defineProps<{
tickerData: TickerType[];
previousData: TickerType[];
status: Status;
}>();
const triangleFilter = ref('filterGreen');
const tickData = props.tickerData;
const prevData = props.previousData;
const prevFilter = triangleFilter.value;
onMounted(() => {
if (prevData.price > tickData.price) {

Check failure on line 18 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, ubuntu-20.04)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 18 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, ubuntu-20.04)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 18 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, ubuntu-20.04)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 18 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, ubuntu-20.04)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 18 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, macos-latest)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 18 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, macos-latest)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 18 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, macos-latest)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 18 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, macos-latest)

Property 'price' does not exist on type 'TickerType[]'.
triangleFilter.value = 'filterRed';
} else if (prevData.price < tickData.price) {

Check failure on line 20 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, ubuntu-20.04)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 20 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, ubuntu-20.04)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 20 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, ubuntu-20.04)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 20 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, macos-latest)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 20 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, macos-latest)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 20 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, macos-latest)

Property 'price' does not exist on type 'TickerType[]'.
triangleFilter.value = 'filterGreen';
} else {
triangleFilter.value = prevFilter;
}
});
</script>

<template>
<header>
<div class="wrapper">
<div v-if="props.status == 'connecting'" class="info">
<h1>ETH-USD</h1>
<h1 class="green price">Connecting...</h1>
</div>
<div v-else-if="props.status == 'connected'" class="info">
<h1>{{ props.tickerData.id }} (Coinbase)</h1>

Check failure on line 36 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, ubuntu-20.04)

Property 'id' does not exist on type 'TickerType[]'.

Check failure on line 36 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, macos-latest)

Property 'id' does not exist on type 'TickerType[]'.
<div class="value">
<img src="@/assets/triangle.svg" class="triangle" :class="triangleFilter" />
<h1 class="green price">${{ props.tickerData.price }}</h1>

Check failure on line 39 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, ubuntu-20.04)

Property 'price' does not exist on type 'TickerType[]'.

Check failure on line 39 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, macos-latest)

Property 'price' does not exist on type 'TickerType[]'.
</div>
<h1>Volume: ${{ props.tickerData.volume }}</h1>

Check failure on line 41 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, ubuntu-20.04)

Property 'volume' does not exist on type 'TickerType[]'.

Check failure on line 41 in src/views/Grid.vue

View workflow job for this annotation

GitHub Actions / build (20.x, macos-latest)

Property 'volume' does not exist on type 'TickerType[]'.
</div>
<div v-else class="info">
<h1>Stock Tracker</h1>
</div>
</div>
</header>
</template>

<style scoped>
header {
line-height: 1.5;
}
.info {
text-align: center;
}
h1 {
font-weight: 500;
font-size: 2.6rem;
position: relative;
top: -10px;
}
h3 {
font-size: 1.2rem;
}
.value {
display: inline-flex;
align-items: center;
text-align: center;
}
.triangle {
height: 30px;
width: auto;
position: relative;
top: -7px;
}
.price {
vertical-align: middle;
}
@media (min-width: 1024px) {
header {
display: flex;
place-items: center;
}
header .wrapper {
display: flex;
place-items: flex-start;
flex-wrap: wrap;
}
.info {
text-align: left;
}
}
</style>

0 comments on commit 33c589b

Please sign in to comment.