Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Leaf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Piotr Kazala CSM2020
Leaf
Commits
616eabe4
Commit
616eabe4
authored
1 year ago
by
Piotrek
Browse files
Options
Downloads
Patches
Plain Diff
Feat: Implemented listener that hides and shows the CSUI on action button click
parent
fb588584
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Fix: Figured out the issue regarding ts not seeing chrome types + fixed...
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
background/index.ts
+19
-1
19 additions, 1 deletion
background/index.ts
content.svelte
+34
-14
34 additions, 14 deletions
content.svelte
popup.svelte
+0
-15
0 additions, 15 deletions
popup.svelte
with
53 additions
and
30 deletions
background/index.ts
+
19
−
1
View file @
616eabe4
...
...
@@ -2,4 +2,22 @@ export {}
console
.
log
(
"
Live now; make now always the most precious time. Now will never come again.
"
)
\ No newline at end of file
)
/**
* Listener that reacts to users clicking on the chrome action button
* It first grabs the current state of the content script UI
* from the chrome.storage API and depending on its current value
* either hides or displays the popup window
*/
chrome
.
action
.
onClicked
.
addListener
(()
=>
{
chrome
.
storage
.
sync
.
get
([
"
visible
"
]).
then
((
result
)
=>
{
if
(
result
.
visible
)
{
chrome
.
storage
.
sync
.
set
({
visible
:
false
})
console
.
log
(
"
im here where i want
"
)
}
else
{
chrome
.
storage
.
sync
.
set
({
visible
:
true
})
console
.
log
(
"
im here where i dont want
"
)
}
})
console
.
log
(
currentState
)
})
This diff is collapsed.
Click to expand it.
content.svelte
+
34
−
14
View file @
616eabe4
...
...
@@ -3,14 +3,9 @@
import
cssText
from
"
data-text:~style.css
"
import
{
sendToBackground
}
from
"
@plasmohq/messaging
"
import
{
Storage
}
from
"
@plasmohq/storage
"
import
Rating
from
"
~rating.svelte
"
let
visible
=
true
const
storage
=
new
Storage
()
//const [visible, setVisible] = useStorage("visible", true)
export
const
getStyle
=
()
=>
{
const
style
=
document
.
createElement
(
"
style
"
)
style
.
textContent
=
cssText
...
...
@@ -19,11 +14,32 @@
</script>
<script>
import
{
onMount
}
from
"
svelte
"
import
{
Storage
}
from
"
@plasmohq/storage
"
let
visible
=
false
const
storage
=
new
Storage
()
onMount
(
async
()
=>
{
await
storage
.
set
(
"
visible
"
,
false
)
})
storage
.
watch
({
visible
:
(
c
)
=>
{
visible
=
c
.
newValue
}
})
let
brand
=
""
let
environmental
=
""
let
supply
=
""
let
social
=
""
let
visible
=
true
function
closePopup
()
{
chrome
.
storage
.
sync
.
set
({
visible
:
false
})
}
async
function
getPokemon
()
{
const
resp
=
await
sendToBackground
({
...
...
@@ -39,24 +55,28 @@
social
=
"
N/A
"
}
else
{
brand
=
resp
.
answer
.
brand
environmental
=
(
Math
.
round
(
resp
.
answer
.
environmental_total
/
1.75
*
100
)).
toString
()
supply
=
(
Math
.
round
(
resp
.
answer
.
supplychain_total
/
6
*
100
)).
toString
()
social
=
(
Math
.
round
(
resp
.
answer
.
social_total
/
3.25
*
100
)).
toString
()
environmental
=
Math
.
round
(
(
resp
.
answer
.
environmental_total
/
1.75
)
*
100
).
toString
()
supply
=
Math
.
round
((
resp
.
answer
.
supplychain_total
/
6
)
*
100
).
toString
()
social
=
Math
.
round
((
resp
.
answer
.
social_total
/
3.25
)
*
100
).
toString
()
visible
=
true
}
return
brand
}
getPokemon
()
</script>
{
#if
visible
}
<section
class=
"p-2 font-roboto font-normal fixed top-10 right-10 w-80 bg-gray-800 rounded-xl text-white"
>
<section
class=
"p-2 font-roboto font-normal fixed top-10 right-10 w-80 bg-gray-800 rounded-xl text-white"
>
<div
class=
"grid grid-cols-2"
>
<div
class=
"flex gap-2 items-center"
>
<h2
class=
"text-xl font-bold"
>
Leaf
</h2>
<img
class=
"w-6 h-6"
src=
{
logo
}
alt=
"Leaf logo"
/>
</div>
<button
on:click=
{
()
=>
(
visible
=
false
)
}
on:click=
{
()
=>
closePopup
(
)
}
class=
"justify-self-end mr-3 text-2xl"
>
x
</button>
</div>
<div>
...
...
@@ -84,5 +104,5 @@
Fashion Transparency Index
</a>
</p>
</section>
{
/if
}
\ No newline at end of file
</section>
{
/if
}
This diff is collapsed.
Click to expand it.
popup.svelte
deleted
100644 → 0
+
0
−
15
View file @
fb588584
<script
lang=
"ts"
>
import
"
./style.css
"
import
logo
from
"
data-base64:~assets/icon.development.png
"
let
data
=
""
</script>
<section
class=
"p-2"
>
<div
class=
"flex gap-2 items-center"
>
<h2
class=
"text-xl font-bold"
>
Leaf
</h2>
<img
class=
"w-6 h-6"
src=
{
logo
}
alt=
"Leaf logo"
/>
</div>
<input
bind:value=
{
data
}
/>
<a
href=
"https://docs.plasmo.com"
target=
"_blank"
>
View Docs
</a>
</section>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment