From 5de3797797b55ef048677138df04db67cf0de696 Mon Sep 17 00:00:00 2001 From: log101 Date: Tue, 16 Jan 2024 17:57:13 +0300 Subject: [PATCH] feat: unlock content based on location --- prettierrc.json | 18 +++ public/blue-dot.png | Bin 0 -> 1065 bytes src/components/LockedContent.tsx | 81 +++++++++++++ src/pages/index.astro | 78 +++++------- src/pages/unlocked.astro | 198 +++++++++++++++++++++++++++++++ src/styles/locked-content.css | 23 ++++ tsconfig.json | 4 +- 7 files changed, 348 insertions(+), 54 deletions(-) create mode 100644 prettierrc.json create mode 100644 public/blue-dot.png create mode 100644 src/components/LockedContent.tsx create mode 100644 src/pages/unlocked.astro create mode 100644 src/styles/locked-content.css diff --git a/prettierrc.json b/prettierrc.json new file mode 100644 index 0000000..38462e4 --- /dev/null +++ b/prettierrc.json @@ -0,0 +1,18 @@ +{ + "endOfLine": "lf", + "printWidth": 120, + "arrowParens": "avoid", + "bracketSpacing": true, + "htmlWhitespaceSensitivity": "css", + "insertPragma": false, + "bracketSameLine": false, + "jsxSingleQuote": true, + "proseWrap": "preserve", + "quoteProps": "as-needed", + "requirePragma": false, + "semi": false, + "singleQuote": false, + "tabWidth": 2, + "trailingComma": "none", + "useTabs": false +} diff --git a/public/blue-dot.png b/public/blue-dot.png new file mode 100644 index 0000000000000000000000000000000000000000..1856f480960e2326c04b022138b99f738f695dc9 GIT binary patch literal 1065 zcmV+^1lIeBP)004R= z004l4008;_004mL004C`008P>0026e000+nl3&F}00009a7bBm000XT000XT0n*)m z`~Uz0uSrBfR7gv;R!dJ4Q4~I{79SV|1!bc#MkQJ#YD|=fVWA01N;}g|3us*smnLA` z8zd$YO!PlsGzK&Q`j~1YDY!7W@Ud{Ch;I^MVHBazcBbPw7b>)!I~^Y0WHPnwow6IAOM93K7(?d_?h9LeA7?b!lCpawh< zH@L&+L6jTu-H`FnnhVsMVzALW|v2_}_Z@L_f z37c^}Mg5Mqd&cN>kM{jXi3tB(b7iX=l^~wxbQBp}(YI?v@#EXnMNk!{e zr|Ar)L^1|SgTxv&ZqX>mWMdA@eYWSKNtZ_vez zr`u*Ocg7yW5;7V>pgLc?^Y!kW|Al@Z_@5N!zimo*F{3-uN?B5wQto)8oAQIEceoz! zTrsdmK5ZUw@lL6G133GRAbY>**i)U7F4Xt$SRQD`SDFPHBX%GL)WqqkB!;~B_OZ6g jN)cs{LL@!kY6kExl|%Q~*0B { + const [isLocked, setIsLocked] = useState(true); + + useEffect(() => { + setInterval( + () => + navigator.geolocation.getCurrentPosition( + (position: GeolocationPosition) => { + const pos = { + lat: position.coords.latitude, + lng: position.coords.longitude, + }; + + const totalDistanceInKM = distance( + pos.lat, + pos.lng, + pos.lat, + pos.lng + ).toFixed(0); + + if (totalDistanceInKM === "0") { + setIsLocked(false); + } + } + ), + 3000 + ); + }, []); + + if (isLocked) { + return ( +
+
+
+ +
+ + + + İçeriği görmek için konuma gitmelisin! + + +
+
+ ); + } else { + return ( +
+
+ + + + + İçeriği görmek için butona bas! + + +
+
+ ); + } +}; + +export default LocationButton; diff --git a/src/pages/index.astro b/src/pages/index.astro index 9df5626..9232e47 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -11,9 +11,9 @@ import { } from '@/components/ui/card'; import { CalendarIcon } from '@radix-ui/react-icons'; -import { LockClosedIcon } from '@radix-ui/react-icons'; import '../styles/locked-page.css'; +import LocationButton from '@/components/LockedContent'; --- @@ -36,23 +36,10 @@ import '../styles/locked-page.css';
-
-
- - - - İçeriği görmek için konuma gitmelisin! - - -
-
- - + + +
- - diff --git a/src/pages/unlocked.astro b/src/pages/unlocked.astro new file mode 100644 index 0000000..da6a201 --- /dev/null +++ b/src/pages/unlocked.astro @@ -0,0 +1,198 @@ +--- +import '@/styles/globals.css'; +import Layout from '../layouts/Layout.astro'; +import { Button } from '@/components/ui/button'; +import { + Card, + CardContent, + CardFooter, + CardHeader, + CardTitle, +} from '@/components/ui/card'; + +import { CalendarIcon } from '@radix-ui/react-icons'; +import { LockClosedIcon } from '@radix-ui/react-icons'; + +import '../styles/locked-page.css'; +--- + + +
+ + + Ayşe + + +

+ Senin için bir sürpriz hazırladım, ama önce aşağıdaki konuma gitmen + lazım 😘 +

+
+ + +

5 saat önce

+
+
+ +
+ +
+
+ + + + İçeriği görmek için konuma gitmelisin! + + +
+
+ + +
+
+ + + + diff --git a/src/styles/locked-content.css b/src/styles/locked-content.css new file mode 100644 index 0000000..5b65507 --- /dev/null +++ b/src/styles/locked-content.css @@ -0,0 +1,23 @@ +.module { + display: grid; + place-items: center; + position: relative; + overflow: hidden; +} + +.module::before { + content: ""; + top: 0; + left: 0; + width: 100%; + height: 100%; + position: absolute; + background-image: url("/sample-selfie.webp"); + background-position: center; + background-repeat: no-repeat; + filter: blur(20px); +} + +.module-inside { + position: relative; +} diff --git a/tsconfig.json b/tsconfig.json index 92402b2..c05caa2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,9 +5,7 @@ "jsxImportSource": "react", "baseUrl": ".", "paths": { - "@/*": [ - "./src/*" - ] + "@/*": ["./src/*"] } } }