Skip to content

Commit

Permalink
fix(js): index.js to index.ts and add type
Browse files Browse the repository at this point in the history
  • Loading branch information
Debaerdm committed Dec 16, 2020
1 parent 8f5cff1 commit 8d2c0c8
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
[Views.Settings]: Settings,
};
let currentView = Views.List;
const onViewChange = view => (currentView = view);
let currentView: Views = Views.List;
const onViewChange = (view: Views) => (currentView = view);
</script>

<style>
Expand Down
3 changes: 0 additions & 3 deletions src/components/Accounts/index.js

This file was deleted.

1 change: 1 addition & 0 deletions src/components/Accounts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Accounts.svelte';
3 changes: 0 additions & 3 deletions src/components/List/index.js

This file was deleted.

1 change: 1 addition & 0 deletions src/components/List/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './List.svelte';
3 changes: 0 additions & 3 deletions src/components/Main/index.js

This file was deleted.

1 change: 1 addition & 0 deletions src/components/Main/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Main.svelte';
11 changes: 6 additions & 5 deletions src/components/Navigation/Navigation.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<script lang="ts">
import Icons from '../icons';
import { Views } from 'models/skizzle/ViewsEnum';
export let currentView;
export let onViewChange;
export let currentView: Views;
export let onViewChange: Function;
const setView = view => () => onViewChange(view);
$: getClass = view => `${view} ${currentView === view ? 'selected' : ''}`;
$: getColor = view => (currentView === view ? `#fff` : '#d3d3d3');
const setView = (view: Views) => () => onViewChange(view);
$: getClass = (view: Views) => `${view} ${currentView === view ? 'selected' : ''}`;
$: getColor = (view: Views) => (currentView === view ? `#fff` : '#d3d3d3');
</script>

<style>
Expand Down
3 changes: 0 additions & 3 deletions src/components/Navigation/index.js

This file was deleted.

1 change: 1 addition & 0 deletions src/components/Navigation/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Navigation.svelte';
13 changes: 12 additions & 1 deletion src/components/Pullrequest/Pullrequest.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
import type { PullRequestType } from "models/skizzle/PullRequestType";
import { Service } from "services/Service";
import Labels from '../Labels';
import { createEventDispatcher } from "svelte";
import { isFetchingData } from '../../shared/stores/default.store';
export let pullRequest: PullRequestType;
const dispatch = createEventDispatcher();
const getComments = (pullRequest: PullRequestType) => {
dispatch('comments', {
fetchedComment: Service.getComments(pullRequest.provider, { pullRequest })
});
}
</script>

<style src="./PullRequest.scss"></style>
Expand Down Expand Up @@ -37,6 +47,7 @@
<p class="skz-pullrequest__repo">{pullRequest.repositoryName}</p>
<div class="skz-pullrequest-infos">
<Labels labels={pullRequest.labels} />
<button on:click={() => getComments(pullRequest)} disabled={$isFetchingData}>Comments</button>
</div>
</div>
</div>
</div>
3 changes: 0 additions & 3 deletions src/components/Settings/index.js

This file was deleted.

1 change: 1 addition & 0 deletions src/components/Settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Settings.svelte';
4 changes: 2 additions & 2 deletions src/components/icons/accounts.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
export let color;
<script lang="ts">
export let color: string;
</script>

<svg
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/components/icons/list.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
export let color;
<script lang="ts">
export let color: string;
</script>

<svg
Expand Down
4 changes: 2 additions & 2 deletions src/components/icons/settings.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
export let color;
<script lang="ts">
export let color: string;
</script>

<svg
Expand Down
24 changes: 22 additions & 2 deletions src/pages/Home.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
<script lang="ts">
import { pullRequests } from '../shared/stores/default.store';
import PullRequest from '../components/PullRequest';
import type { CommentType } from 'models/skizzle/CommentType';
import { Service } from 'services/Service';
$: fetchedComments = Promise.resolve<CommentType[]>([])
</script>

{#each $pullRequests.sort((a, b) => Date.parse(b.date) - Date.parse(a.date)) as pullRequest}
<PullRequest {pullRequest} />
{/each}
<PullRequest {pullRequest} on:comments={(event) => fetchedComments = event.detail.fetchedComment}/>
{/each}

<div style="color: white;">
{#await fetchedComments then comments}
{#each comments as comment}
{#await Service.getAvatar(comment.provider, comment.author.avatar, comment.organizationName) then avatar}
<img width="64" height="64" src={avatar} alt={comment.author.displayName} />
{/await}
<p>Name: {comment.author.displayName}</p>
<p>Date: {comment.date}</p>
<p>Text: {comment.text}</p>
<p>Provider: {comment.provider}</p>
{:else}
<p>Aucun commentaire</p>
{/each}
{/await}
</div>

0 comments on commit 8d2c0c8

Please sign in to comment.