Skip to content

Commit

Permalink
Merge pull request #220 from sinankambran/github-btn
Browse files Browse the repository at this point in the history
GitHub button completed
  • Loading branch information
Muhammed-Rahif authored Nov 15, 2024
2 parents 4455347 + f167fc5 commit 5d2606c
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 40 deletions.
33 changes: 22 additions & 11 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Prettier
on:
pull_request:
branches:
- alpha
# pull_request_target:
# types:
# - opened
# - synchronize
# - reopened
# - edited
# branches:
# - alpha
workflow_dispatch:
jobs:
prettier:
Expand All @@ -14,9 +19,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
# https://github.com/actions/checkout/issues/455#issuecomment-792228083
ref: ${{ github.event_name == 'workflow_dispatch' && github.ref || github.event.pull_request.head.ref }}
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
Expand All @@ -27,8 +30,16 @@ jobs:
run: npm install

- name: Run Prettier
uses: creyD/[email protected]
with:
prettier_options: --write .
commit_message: 'style(prettier): run prettier'
prettier_plugins: 'prettier-plugin-svelte prettier-plugin-tailwindcss'
run: npx prettier --write .

- name: Commit changes
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m 'style(prettier): run prettier' || echo "No changes to commit"
- name: Push changes
run: git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 17 additions & 16 deletions src/lib/components/DownloadButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import LinuxIcon from '@/components/icons/Linux.svelte';
import MacOSIcon from '@/components/icons/MacOS.svelte';
import DownloadIcon from '@/components/icons/Download.svelte';
import { slide } from 'svelte/transition';
function getContentForDownloadUrl(fileUrl: string) {
const fileName = fileUrl.split('/').pop();
Expand All @@ -25,22 +26,22 @@
.flatMap((release) => release.assets)
.sort((a, b) => a.name.localeCompare(b.name))}

<Menubar.Menu>
<Menubar.Trigger class="absolute right-1 top-1/2 -translate-y-1/2 transform">
Download
</Menubar.Trigger>
<Menubar.Content>
{#each assets as asset}
{@const { text, icon: Icon } = getContentForDownloadUrl(asset.name)}
<a href={asset.browser_download_url} download={asset.browser_download_url}>
<Menubar.Item class="flex items-center justify-between">
{text}
<div transition:slide|global class="absolute right-1 top-1/2 -translate-y-1/2 transform">
<Menubar.Menu>
<Menubar.Trigger>Download</Menubar.Trigger>
<Menubar.Content>
{#each assets as asset}
{@const { text, icon: Icon } = getContentForDownloadUrl(asset.name)}
<a href={asset.browser_download_url} download={asset.browser_download_url}>
<Menubar.Item class="flex items-center justify-between">
{text}

<Icon class="text-xl" />
</Menubar.Item>
</a>
{/each}
</Menubar.Content>
</Menubar.Menu>
<Icon class="text-xl" />
</Menubar.Item>
</a>
{/each}
</Menubar.Content>
</Menubar.Menu>
</div>
{/if}
{/await}
22 changes: 17 additions & 5 deletions src/lib/components/MenuBar.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<script lang="ts">
import * as Menubar from '@/components/ui/menubar';
import EditorTitle from '@/components/EditorTitle.svelte';
import DownloadButton from './DownloadButton.svelte';
import DownloadButton from '@/components/DownloadButton.svelte';
import { Notpad } from '@/helpers/notpad';
import { editors, settings } from '@/store/store';
import { fade } from 'svelte/transition';
import { isTauri } from '@/src/lib';
import screenfull from 'screenfull';
import { toggleMode, mode } from 'mode-watcher';
import { onMount } from 'svelte';
import { openFontDialog } from './font-dialog/FontDialog.svelte';
import { openFontDialog } from '@/components/font-dialog/FontDialog.svelte';
import { openAboutDialog } from '@/components/AboutDialog.svelte';
import { toggleGoToDialog } from './GoToDialog.svelte';
import { toggleFindDialog } from './FindDialog.svelte';
import { toggleGoToDialog } from '@/components/GoToDialog.svelte';
import { toggleFindDialog } from '@/components/FindDialog.svelte';
import GitHubIcon from '@/components/icons/GitHub.svelte';
import InfoIcon from './icons/Info.svelte';
import GithubOultineIcon from './icons/GithubOultine.svelte';
let innerWidth = window.innerWidth;
let isFullScreen = screenfull.isFullscreen;
Expand Down Expand Up @@ -137,7 +140,16 @@
<Menubar.Menu>
<Menubar.Trigger>Help</Menubar.Trigger>
<Menubar.Content>
<Menubar.Item on:click={openAboutDialog}>About Notpad</Menubar.Item>
<a href="https://github.com/Muhammed-Rahif/Notpad" target="_blank">
<Menubar.Item class="flex items-center gap-2">
<GithubOultineIcon class="text-xl" />
Github
</Menubar.Item>
</a>
<Menubar.Item class="flex items-center gap-2" on:click={openAboutDialog}>
<InfoIcon class="text-xl" />
About Notpad
</Menubar.Item>
</Menubar.Content>
</Menubar.Menu>

Expand Down
6 changes: 6 additions & 0 deletions src/lib/components/icons/GithubOultine.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...$$props}
><path
fill="currentColor"
d="M12 0a12 12 0 1 0 0 24a12 12 0 0 0 0-24m3.163 21.783h-.093a.5.5 0 0 1-.382-.14a.5.5 0 0 1-.14-.372v-1.406q.01-.701.01-1.416a3.7 3.7 0 0 0-.151-1.028a1.83 1.83 0 0 0-.542-.875a8 8 0 0 0 2.038-.471a4.05 4.05 0 0 0 1.466-.964c.407-.427.71-.943.885-1.506a6.8 6.8 0 0 0 .3-2.13a4.1 4.1 0 0 0-.26-1.476a3.9 3.9 0 0 0-.795-1.284a2.8 2.8 0 0 0 .162-.582q.05-.3.05-.604q0-.392-.09-.773a5 5 0 0 0-.221-.763a.3.3 0 0 0-.111-.02h-.11q-.346.004-.674.111a5 5 0 0 0-.703.26a7 7 0 0 0-.661.343q-.322.191-.573.362a9.6 9.6 0 0 0-5.143 0a14 14 0 0 0-.572-.362a6 6 0 0 0-.672-.342a4.5 4.5 0 0 0-.705-.261a2.2 2.2 0 0 0-.662-.111h-.11a.3.3 0 0 0-.11.02a6 6 0 0 0-.23.763q-.08.382-.081.773q0 .304.051.604t.16.582A3.9 3.9 0 0 0 5.702 10a4.1 4.1 0 0 0-.263 1.476a6.9 6.9 0 0 0 .292 2.12c.181.563.483 1.08.884 1.516c.415.422.915.75 1.466.964c.653.25 1.337.41 2.033.476a1.8 1.8 0 0 0-.452.633a3 3 0 0 0-.2.744a2.75 2.75 0 0 1-1.175.27a1.8 1.8 0 0 1-1.065-.3a2.9 2.9 0 0 1-.752-.824a3 3 0 0 0-.292-.382a2.7 2.7 0 0 0-.372-.343a1.8 1.8 0 0 0-.432-.24a1.2 1.2 0 0 0-.481-.101q-.06.002-.12.01a.7.7 0 0 0-.162.02a.4.4 0 0 0-.13.06a.12.12 0 0 0-.06.1a.33.33 0 0 0 .14.242q.14.111.232.171l.03.021q.2.155.382.333q.169.148.3.33q.136.178.231.381q.11.2.231.463c.188.474.522.875.954 1.145c.453.243.961.364 1.476.351q.262 0 .522-.03q.258-.041.515-.091v1.743a.5.5 0 0 1-.533.521h-.062a10.286 10.286 0 1 1 6.324 0z"
/></svg
>
9 changes: 9 additions & 0 deletions src/lib/components/icons/Info.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...$$props}
><g
fill="none"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"><circle cx="12" cy="12" r="10" /><path d="M12 16v-4m0-4h.01" /></g
></svg
>
16 changes: 8 additions & 8 deletions src/lib/helpers/github-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ export interface ContributorType {
}

export interface ReleasesType {
assets: Asset[];
assets: Asset[];
}

export interface Asset {
name: string;
url: string;
content_type: string;
size: number;
download_count: number;
created_at: Date;
updated_at: Date;
name: string;
url: string;
content_type: string;
size: number;
download_count: number;
created_at: Date;
updated_at: Date;
browser_download_url: string;
}

Expand Down

0 comments on commit 5d2606c

Please sign in to comment.