Skip to content

Commit e0aadc6

Browse files
committed
fix: showing tick mark in all clipboard button on copy action
1 parent 6b2ca68 commit e0aadc6

File tree

3 files changed

+110
-19
lines changed

3 files changed

+110
-19
lines changed

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,44 @@
11
# offline-diff-viewer
22

3-
## Why another diff viewer
3+
## Why another diff viewer and motivation behind the tool
4+
5+
## Resoning for building yet another diff viewer tool
46

57
I realise we are missing a diff viewer that is
68

79
- Privacy focused
810
- Simple to use
911
- And most importantly does not store any data on server to give sharable diff urls
1012

13+
## Motivation
14+
15+
I realise as a developer community we are missing on a diff viewer tool that does not store your data on their server to give you links to diff view to share with your teams.
16+
There can be serious implications of storing your enterprise data on some server that you don’t know anything about
17+
18+
Also due to lack of such tool, if you want to see the the diff again you have to do the following
19+
20+
1. Ask/get the data from someone/somewhere
21+
2. Search for a diff viewer tool online
22+
3. Copy paste the data sources to the tool
23+
4. Compare and share findings
24+
25+
This is still a mechnical part that can be easily automated. But most such tools out there right now store your data to give you sharable diff URLs which was a concerning thing at least for me for security reasons.
26+
27+
The simplest solution in my opinion will be
28+
29+
1. Get the data just once
30+
2. Search for diff tool online just once
31+
3. Copy your data to the tool just once
32+
4. Compare and get a sharable url that stores your data in link itself
33+
34+
In the chase of one such tool I ended up creating one as I did not find any that satisfied my requirements.
35+
This is open source and has very easy user interface. Here is the link to the tool https://diffviewer.vercel.app/
36+
It has following benefits
37+
Since the tool does not store your data on its server there is no server required in the tool
38+
that makes the tools blazing fast
39+
most importantly the link can be shared with anyone without security concerns(Unless you share it over some insecure media)
40+
as the link contains data whomever you share link with can get data too
41+
1142
## Build Setup
1243

1344
```bash

components/RTStickyCopyButton.vue

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<template>
22
<div class="sticky top-0 text-right z-1">
33
<button
4-
@click="clickHandler"
5-
class="absolute top-0 right-0 p-2 transition-all transform bg-gray-100 rounded-full shadow z-1 hover:shadow-lg hover:scale-110 hover:rotate-12"
4+
@click="handleClick"
5+
class="absolute top-0 right-0 p-2 transition-all transform rounded-full shadow z-1 hover:shadow-lg hover:scale-110 hover:rotate-12"
6+
v-bind:class="{
7+
'bg-gray-100': !copied,
8+
'bg-green-500': copied,
9+
}"
610
>
711
<svg
12+
v-show="!copied"
813
class="w-6 h-6"
914
fill="none"
1015
stroke="currentColor"
@@ -18,12 +23,41 @@
1823
d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
1924
></path>
2025
</svg>
26+
<svg
27+
v-show="copied"
28+
class="w-6 h-6"
29+
fill="none"
30+
stroke="currentColor"
31+
viewBox="0 0 24 24"
32+
xmlns="http://www.w3.org/2000/svg"
33+
>
34+
<path
35+
stroke-linecap="round"
36+
stroke-linejoin="round"
37+
stroke-width="2"
38+
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"
39+
></path>
40+
</svg>
2141
</button>
2242
</div>
2343
</template>
2444

2545
<script>
2646
export default {
2747
props: ['clickHandler'],
48+
data() {
49+
return {
50+
copied: false,
51+
}
52+
},
53+
methods: {
54+
handleClick(e) {
55+
this.copied = true
56+
this.clickHandler(e)
57+
setTimeout(() => {
58+
this.copied = false
59+
}, 5000)
60+
},
61+
},
2862
}
2963
</script>

pages/diff/_diff.vue

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,46 @@
55
<button
66
type="button"
77
@click="copyUrlToClipboard"
8-
class="inline-flex justify-center px-4 py-2 text-white transition-transform transform bg-blue-600 rounded-md shadow-lg outline-none copy-uri-button align-center focus:ring-4 active:scale-y-75"
8+
class="inline-flex justify-center px-4 py-2 text-white transition-transform transform rounded-md shadow-lg outline-none copy-uri-button align-center focus:ring-4 active:scale-y-75"
9+
v-bind:class="{
10+
'bg-blue-600 text-white': !copied,
11+
'bg-green-500 text-black': copied,
12+
}"
913
>
10-
<svg
11-
class="w-6 h-6 mr-2"
12-
fill="none"
13-
stroke="currentColor"
14-
viewBox="0 0 24 24"
15-
xmlns="http://www.w3.org/2000/svg"
16-
>
17-
<path
18-
stroke-linecap="round"
19-
stroke-linejoin="round"
20-
stroke-width="2"
21-
d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"
22-
></path>
23-
</svg>
24-
<span>Copy link</span>
14+
<span class="inline-flex justify-center" v-show="copied">
15+
<svg
16+
class="w-6 h-6 mr-2"
17+
fill="none"
18+
stroke="currentColor"
19+
viewBox="0 0 24 24"
20+
xmlns="http://www.w3.org/2000/svg"
21+
>
22+
<path
23+
stroke-linecap="round"
24+
stroke-linejoin="round"
25+
stroke-width="2"
26+
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"
27+
></path>
28+
</svg>
29+
<span>Copied</span>
30+
</span>
31+
<span class="inline-flex justify-center" v-show="!copied">
32+
<svg
33+
class="w-6 h-6 mr-2"
34+
fill="none"
35+
stroke="currentColor"
36+
viewBox="0 0 24 24"
37+
xmlns="http://www.w3.org/2000/svg"
38+
>
39+
<path
40+
stroke-linecap="round"
41+
stroke-linejoin="round"
42+
stroke-width="2"
43+
d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"
44+
></path>
45+
</svg>
46+
<span>Copy link</span>
47+
</span>
2548
</button>
2649
</template>
2750
</Navbar>
@@ -98,6 +121,7 @@ export default {
98121
return {
99122
lhsDiff: this.lhsDiff,
100123
rhsDiff: this.rhsDiff,
124+
copied: false,
101125
}
102126
},
103127
methods: {
@@ -124,8 +148,10 @@ export default {
124148
theme: 'success',
125149
})
126150
this.$store.commit('toast/toggle')
151+
this.copied = true
127152
setTimeout(() => {
128153
this.$store.commit('toast/toggle')
154+
this.copied = false
129155
}, 5000)
130156
setTimeout(() => {
131157
this.$store.commit('toast/clean')

0 commit comments

Comments
 (0)