diff --git a/src/__snapshots__/storybook.test.ts.snap b/src/__snapshots__/storybook.test.ts.snap index ce303573..dc2a9efc 100644 --- a/src/__snapshots__/storybook.test.ts.snap +++ b/src/__snapshots__/storybook.test.ts.snap @@ -3129,12 +3129,13 @@ exports[`Storyshots Made With Love With Love 1`] = ` className="ant-typography hiringLink-0-2-225" data-test="link" href="http://www.linkedin.com" + rel="noopener noreferrer" style={ Object { "WebkitLineClamp": undefined, } } - target="_self" + target="_blank" > We’re hiring! @@ -3152,12 +3153,13 @@ exports[`Storyshots Made With Love With Love 1`] = ` className="ant-typography footerIcon-0-2-221" data-test="link" href="http://www.twitter.com" + rel="noopener noreferrer" style={ Object { "WebkitLineClamp": undefined, } } - target="_self" + target="_blank" > `; +exports[`Storyshots Plausible Disable Plausible 1`] = ` +
+
+
+
+ Plausible Exclude +
+
+ Click the button below to toggle your exclusion in analytics for this site +
+ You currently + + are not + + excluding your visits. +
+
+ +
+
+
+`; + exports[`Storyshots Popover Default 1`] = `
@@ -4773,31 +4827,31 @@ exports[`Storyshots Radio Group Loading 1`] = ` className="light storyWrapper-0-2-2" >
 
 
  @@ -4923,29 +4977,29 @@ exports[`Storyshots ScrollableSection Multiple 1`] = ` >
apple
pineapple
mango
@@ -5081,17 +5135,17 @@ exports[`Storyshots ScrollableSection Scroll Without Arrow 1`] = ` className="light storyWrapper-0-2-2" >
pineapple @@ -5160,20 +5214,20 @@ exports[`Storyshots ScrollableSection Single 1`] = ` className="light storyWrapper-0-2-2" >
hello
Lorem @@ -5446,7 +5500,7 @@ exports[`Storyshots Select Icon 1`] = ` className="decorator-0-2-3" >
AWS @@ -5567,7 +5621,7 @@ exports[`Storyshots Select Search 1`] = ` className="decorator-0-2-3" >
press enter @@ -5795,19 +5849,19 @@ exports[`Storyshots ShortcutMicrocopy Icon Only 1`] = ` className="light storyWrapper-0-2-2" >
press @@ -5821,24 +5875,24 @@ exports[`Storyshots ShortcutMicrocopy Mixed 1`] = ` className="light storyWrapper-0-2-2" >
press cmd @@ -5846,12 +5900,12 @@ exports[`Storyshots ShortcutMicrocopy Mixed 1`] = ` + Enter
press cmd @@ -5908,12 +5962,12 @@ exports[`Storyshots ShortcutMicrocopy Predefined Keys 1`] = ` + enter @@ -5927,7 +5981,7 @@ exports[`Storyshots Skeleton Circle 1`] = ` className="light storyWrapper-0-2-2" >   @@ -5939,27 +5993,27 @@ exports[`Storyshots Skeleton Count 1`] = ` className="light storyWrapper-0-2-2" >           @@ -5971,7 +6025,7 @@ exports[`Storyshots Skeleton Default 1`] = ` className="light storyWrapper-0-2-2" >   @@ -5983,21 +6037,21 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = ` className="light storyWrapper-0-2-2" >
vpc-flow-logs-are-disabled @@ -6329,7 +6383,7 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = ` style={Object {}} >
FlowLog @@ -6364,10 +6418,10 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = ` style={Object {}} >
visibility @@ -6376,7 +6430,7 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = `
instance-is-exposed-to-internet @@ -6405,7 +6459,7 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = ` style={Object {}} >
instance @@ -6440,10 +6494,10 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = ` style={Object {}} >
network @@ -6452,7 +6506,7 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = `
default-security-group-should-not-allow-traffic @@ -6481,7 +6535,7 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = ` style={Object {}} >
security-group @@ -6516,10 +6570,10 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = ` style={Object {}} >
networking @@ -6528,7 +6582,7 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = `
ssh-from-internet @@ -6557,7 +6611,7 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = ` style={Object {}} >
security-group @@ -6592,10 +6646,10 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = ` style={Object {}} >
network @@ -6604,7 +6658,7 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = `
ebs-volume-is-not-encrypted @@ -6633,7 +6687,7 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = ` style={Object {}} >
volume @@ -6668,10 +6722,10 @@ exports[`Storyshots TableDrawer Simple Drawer 1`] = ` style={Object {}} >
cryptography @@ -6934,7 +6988,7 @@ exports[`Storyshots TimeInput Error 1`] = ` className="light storyWrapper-0-2-2" >
Foo
+ +
+ ) +} + +const Template: Story = () => + +export const DisablePlausible = Template.bind({}) diff --git a/src/components/Plausible/index.tsx b/src/components/Plausible/index.tsx new file mode 100644 index 00000000..6378fd8f --- /dev/null +++ b/src/components/Plausible/index.tsx @@ -0,0 +1,86 @@ +import { Button } from 'components/Button' +import { createUseStyles } from 'react-jss' +import { styleguide } from 'components/assets/styles' +import React, { FC, useState } from 'react' + +const { + colors: { blacks, blues, grays, greens, reds }, + flexCenter, + flexDown, + fontWeight, + spacing +} = styleguide + +interface ReactJssProps { + isExcluded: boolean +} + +const useStyles = createUseStyles({ + btn: { + backgroundColor: `${blues.base} !important`, + borderColor: `${blues.base} !important`, + color: `${grays.base} !important` + }, + container: { + ...flexCenter, + ...flexDown, + backgroundColor: blacks.base, + color: grays.base, + height: '100%', + textAlign: 'center' + }, + desc: { + padding: `${spacing.xl}px 0` + }, + exclude: { + color: ({ isExcluded }: ReactJssProps) => + isExcluded ? greens.base : reds.base, + fontWeight: fontWeight.regular * 2, + padding: `0 ${spacing.xs}px` + }, + status: { + paddingBottom: spacing['m+'], + paddingTop: spacing.s + }, + title: { + fontSize: spacing.l * 2, + fontWeight: fontWeight.bold + } +}) + +export const Plausible: FC = () => { + const [isExcluded, setIsExcluded] = useState(localStorage.plausible_ignore) + const classes = useStyles({ isExcluded }) + + const toggleExclusion = () => { + const exclusionState = localStorage.plausible_ignore === 'true' + + if (exclusionState) { + setIsExcluded(false) + delete localStorage.plausible_ignore + } else { + setIsExcluded(true) + localStorage.plausible_ignore = 'true' + } + } + + return ( +
+
Plausible Exclude
+
+ Click the button below to toggle your exclusion in analytics for + this site +
+ You currently + + {isExcluded ? 'are' : 'are not'} + + excluding your visits. +
+
+ +
+ ) +} diff --git a/src/components/index.ts b/src/components/index.ts index c7e4d7fb..b3397995 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -30,6 +30,7 @@ export * from './PageContainer' export * from './PageLoader' export * from './Pages/MadeWithLove' export * from './Pages/Error404' +export * from './Plausible' export * from './Popover' export * from './ProgressBar' export * from './RadioGroup'