feat: social platforms

This commit is contained in:
DIYgod
2023-02-11 01:27:40 +00:00
parent f4cfda0ee8
commit 58645e1dfc
19 changed files with 399 additions and 4 deletions
+1
View File
@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1676076546787" class="icon" viewBox="0 0 1129 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2592" xmlns:xlink="http://www.w3.org/1999/xlink" width="220.5078125" height="200"><path d="M234.909 9.656a80.468 80.468 0 0 1 68.398 0 167.374 167.374 0 0 1 41.843 30.578l160.937 140.82h115.07l160.936-140.82a168.983 168.983 0 0 1 41.843-30.578A80.468 80.468 0 0 1 930.96 76.445a80.468 80.468 0 0 1-17.703 53.914 449.818 449.818 0 0 1-35.406 32.187 232.553 232.553 0 0 1-22.531 18.508h100.585a170.593 170.593 0 0 1 118.289 53.109 171.397 171.397 0 0 1 53.914 118.288v462.693a325.897 325.897 0 0 1-4.024 70.007 178.64 178.64 0 0 1-80.468 112.656 173.007 173.007 0 0 1-92.539 25.75h-738.7a341.186 341.186 0 0 1-72.421-4.024A177.835 177.835 0 0 1 28.91 939.065a172.202 172.202 0 0 1-27.36-92.539V388.662a360.498 360.498 0 0 1 0-66.789A177.03 177.03 0 0 1 162.487 178.64h105.414c-16.899-12.07-31.383-26.555-46.672-39.43a80.468 80.468 0 0 1-25.75-65.984 80.468 80.468 0 0 1 39.43-63.57M216.4 321.873a80.468 80.468 0 0 0-63.57 57.937 108.632 108.632 0 0 0 0 30.578v380.615a80.468 80.468 0 0 0 55.523 80.469 106.218 106.218 0 0 0 34.601 5.632h654.208a80.468 80.468 0 0 0 76.444-47.476 112.656 112.656 0 0 0 8.047-53.109v-354.06a135.187 135.187 0 0 0 0-38.625 80.468 80.468 0 0 0-52.304-54.719 129.554 129.554 0 0 0-49.89-7.242H254.22a268.764 268.764 0 0 0-37.82 0z m0 0" fill="#20B0E3" p-id="2593"></path><path d="M348.369 447.404a80.468 80.468 0 0 1 55.523 18.507 80.468 80.468 0 0 1 28.164 59.547v80.468a80.468 80.468 0 0 1-16.094 51.5 80.468 80.468 0 0 1-131.968-9.656 104.609 104.609 0 0 1-10.46-54.719v-80.468a80.468 80.468 0 0 1 70.007-67.593z m416.02 0a80.468 80.468 0 0 1 86.102 75.64v80.468a94.148 94.148 0 0 1-12.07 53.11 80.468 80.468 0 0 1-132.773 0 95.757 95.757 0 0 1-12.875-57.133V519.02a80.468 80.468 0 0 1 70.007-70.812z m0 0" fill="#20B0E3" p-id="2594"></path></svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

+3
View File
@@ -0,0 +1,3 @@
<svg width="1024" height="1024" viewBox="0 0 1024 1024" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z" transform="scale(64)" fill="#1B1F23"/>
</svg>

After

Width:  |  Height:  |  Size: 968 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

+1
View File
@@ -0,0 +1 @@
<svg fill="none" height="40" viewBox="0 0 40 40" width="40" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="21.0083" x2="21.0083" y1="8" y2="27.1015"><stop offset="0" stop-color="#f0ffff"/><stop offset=".1096" stop-color="#ddfafe"/><stop offset=".331" stop-color="#adebfa"/><stop offset=".6441" stop-color="#60d4f5"/><stop offset=".9994" stop-color="#00b8ee"/></linearGradient><path d="m0 0h40v40h-40z" fill="#f8e026"/><path d="m16.6695 30.4378-2.6089-3.6902c-.1052-.1482-.0698-.3537.0784-.4579l1.7246-1.219c1.7849-1.2619 2.8499-3.0124 2.8499-5.5047v-11.23713c0-.18164.1472-.32887.3289-.32887h4.6042v11.564c0 4.5383-1.2639 6.8021-4.9847 9.4637z" fill="#fff"/><path d="m23.5107 8v11.3709c0 4.5383-1.2638 6.8021-4.9847 9.4637l-1.9933 1.4092.9493 1.3422c.1052.1482.3098.1836.458.0784l1.7342-1.2256c2.2065-1.5784 3.588-3.0296 4.4809-4.7056.9187-1.7246 1.3288-3.6873 1.3288-6.3632v-11.04113c0-.18164-.1472-.32887-.3288-.32887z" fill="url(#a)"/></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

+1
View File
@@ -0,0 +1 @@
<svg fill="none" height="40" viewBox="0 0 40 40" width="40" xmlns="http://www.w3.org/2000/svg"><path d="m0 0h40v40h-40z" fill="#000"/><g fill="#fafcff"><path d="m21.5374 19.8277c0 3.7707-3.0305 6.8275-6.7686 6.8275s-6.7688-3.0575-6.7688-6.8275 3.0305-6.8277 6.7688-6.8277c3.7384 0 6.7686 3.057 6.7686 6.8277z"/><path d="m28.9627 19.8281c0 3.5494-1.5153 6.4278-3.3844 6.4278-1.8692 0-3.3845-2.8784-3.3845-6.4278 0-3.5493 1.5151-6.4277 3.3842-6.4277 1.8692 0 3.3845 2.8775 3.3845 6.4277"/><path d="m32 19.8276c0 3.1793-.5328 5.7582-1.1903 5.7582s-1.1901-2.5782-1.1901-5.7582.5329-5.7583 1.1901-5.7583c.6573 0 1.1903 2.578 1.1903 5.7583z"/></g></svg>

After

Width:  |  Height:  |  Size: 647 B

+1
View File
@@ -0,0 +1 @@
<svg height="512px" style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512" width="512px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="#e60012"><g id="comp_x5F_232-nintendo-switch"><g><path d="M124.432,27.526c-45.786,8.212-82.641,42.09-94.241,86.644c-4.208,16.118-4.517,25.562-4.003,150.398 c0.204,114.566,0.308,117.235,2.258,126.168c10.574,47.734,44.452,81.718,92.702,92.906c6.262,1.437,14.269,1.745,65.804,1.951 c53.28,0.411,58.824,0.307,60.261-1.131c1.436-1.437,1.54-19.813,1.54-228.109c0-154.503-0.307-227.185-0.923-228.521 c-0.924-1.744-2.566-1.847-58.413-1.744C144.041,26.192,130.388,26.5,124.432,27.526L124.432,27.526z M210.564,256.046v192.896 l-38.806-0.512c-35.725-0.411-39.523-0.614-46.709-2.359c-30.694-7.907-53.383-31.52-59.851-62.316 c-2.053-9.649-2.053-246.486-0.103-255.931c5.749-26.795,24.331-48.968,49.276-58.926c12.524-5.031,18.376-5.646,59.132-5.749 l36.854-0.103v193H210.564z M132.645,121.357c-5.954,1.129-15.09,5.75-20.018,9.958c-9.958,8.623-14.988,20.942-14.167,35.417 c0.411,7.495,0.821,9.548,3.901,15.604c4.517,9.239,11.189,16.015,20.43,20.532c6.365,3.183,8.007,3.491,16.322,3.799 c7.493,0.306,10.163,0,15.194-1.747c20.634-6.981,33.159-27,29.565-47.633C179.869,132.957,156.565,116.533,132.645,121.357z M295.052,26.602c-0.409,0.308-0.613,103.48-0.613,229.444c0,207.682,0.101,228.727,1.538,229.342 c2.566,0.924,76.481,0.617,85.619-0.411c38.701-4.414,72.888-27.923,91.366-62.827c2.361-4.517,5.543-12.011,7.186-16.631 c5.955-17.864,5.852-13.141,5.852-149.986c0-109.229-0.203-125.552-1.54-132.429c-9.443-49.586-47.324-87.057-97.012-95.577 c-6.674-1.129-16.939-1.437-50.099-1.437C314.353,25.986,295.362,26.294,295.052,26.602z M396.789,234.077 c14.886,3.902,26.999,15.193,32.03,29.668c3.181,8.933,3.08,22.071-0.105,30.287c-5.849,15.089-17.245,25.663-31.925,29.564 c-23.817,6.161-49.175-8.211-56.054-31.823c-2.053-7.188-1.949-19.405,0.41-26.899 C348.231,241.571,372.972,227.815,396.789,234.077L396.789,234.077z"/></g></g><g id="Layer_1"/></svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

+1
View File
@@ -0,0 +1 @@
<svg fill="none" height="40" viewBox="0 0 40 40" width="40" xmlns="http://www.w3.org/2000/svg"><path d="m0 0h40v40h-40z" fill="#3e97f3"/><path d="m21.009 10.1378c-3.4053.0634-7.5174 1.628-12.07004 5.5825l1.21254 2.6275.66-.3825v-1.355c.3916-.7864.9387-1.5096 2.0125-2.015v15.1525h-.5575l.005.54h3.78v-.525h-.5675v-3.82c21.099 4.7277 18.2633-16.04231 5.525-15.805zm-.1575 1.46c10.2013.0715 10.4375 18.0336-5.3675 12.6475v-11.2725c2.0079-.9765 3.8051-1.386 5.3675-1.375z" fill="#fff" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width=".5"/></svg>

After

Width:  |  Height:  |  Size: 568 B

+1
View File
@@ -0,0 +1 @@
<svg class="bi bi-playstation" fill="#0070d1" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M15.858 11.451c-.313.395-1.079.676-1.079.676l-5.696 2.046v-1.509l4.192-1.493c.476-.17.549-.412.162-.538-.386-.127-1.085-.09-1.56.08l-2.794.984v-1.566l.161-.054s.807-.286 1.942-.412c1.135-.125 2.525.017 3.616.43 1.23.39 1.368.962 1.056 1.356ZM9.625 8.883v-3.86c0-.453-.083-.87-.508-.988-.326-.105-.528.198-.528.65v9.664l-2.606-.827V2c1.108.206 2.722.692 3.59.985 2.207.757 2.955 1.7 2.955 3.825 0 2.071-1.278 2.856-2.903 2.072Zm-8.424 3.625C-.061 12.15-.271 11.41.304 10.984c.532-.394 1.436-.69 1.436-.69l3.737-1.33v1.515l-2.69.963c-.474.17-.547.411-.161.538.386.126 1.085.09 1.56-.08l1.29-.469v1.356l-.257.043a8.454 8.454 0 0 1-4.018-.323Z"/></svg>

After

Width:  |  Height:  |  Size: 781 B

+4
View File
@@ -0,0 +1,4 @@
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="40" height="40" fill="#FF6719"/>
<path d="M27.0527 17.4947H13V15.604H27.0533V17.4947H27.0527ZM13 19.208V28L20.0267 24.0733L27.0533 28V19.208H13ZM27.0533 12H13V13.8907H27.0533V12Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 311 B

+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-1">
<stop stop-color="#38AEEB" offset="0%"></stop>
<stop stop-color="#279AD1" offset="100%"></stop>
</linearGradient>
</defs>
<g id="Artboard" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<circle id="Oval" fill="url(#linearGradient-1)" cx="8" cy="8" r="8"></circle>
<path d="M3.17026167,7.83635602 C5.78750201,6.74265999 7.53273882,6.02162863 8.40597211,5.67326193 C10.8992306,4.67860423 11.2454541,4.53439191 11.5831299,4.52864956 C11.6573986,4.52743168 11.8385417,4.55776042 11.9798438,4.67645833 C12.1211458,4.79515625 12.1635786,4.87206678 12.1755371,4.93908691 C12.1874957,5.00610705 12.1862759,5.21456762 12.1744385,5.3338623 C12.0393279,6.69547283 11.5259342,9.83829771 11.2285121,11.3633248 C11.1026617,12.008621 10.8548582,12.2249854 10.6149558,12.2461596 C10.0935924,12.2921758 9.69769267,11.9156852 9.19272668,11.5981993 C8.40255458,11.1013965 8.13911734,10.9180161 7.3721185,10.4332283 C6.48571864,9.87297217 6.85080034,9.6784879 7.35595703,9.17524981 C7.48815894,9.04355001 9.67825076,7.04590073 9.71077046,6.86250183 C9.7391276,6.70257812 9.7494847,6.68189389 9.67664063,6.60973958 C9.60379655,6.53758527 9.51674192,6.54658941 9.46083149,6.55876051 C9.38158015,6.57601267 8.17521836,7.33962686 5.84174612,8.84960308 C5.48344358,9.08558775 5.15890428,9.20056741 4.86812819,9.19454205 C4.54757089,9.18789957 3.93094724,9.02070014 3.47255094,8.87778221 C2.91030922,8.70248755 2.46345069,8.609808 2.50236203,8.31210343 C2.52262946,8.15704047 2.74526267,7.998458 3.17026167,7.83635602 Z" id="Path-3" fill="#FFFFFF"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

+1
View File
@@ -0,0 +1 @@
<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg height="100%" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;" version="1.1" viewBox="0 0 512 512" width="100%" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:serif="http://www.serif.com/" xmlns:xlink="http://www.w3.org/1999/xlink"><rect height="400" style="fill:none;" width="400" x="56" y="56"/><path d="M161.014,464.013c193.208,0 298.885,-160.071 298.885,-298.885c0,-4.546 0,-9.072 -0.307,-13.578c20.558,-14.871 38.305,-33.282 52.408,-54.374c-19.171,8.495 -39.51,14.065 -60.334,16.527c21.924,-13.124 38.343,-33.782 46.182,-58.102c-20.619,12.235 -43.18,20.859 -66.703,25.498c-19.862,-21.121 -47.602,-33.112 -76.593,-33.112c-57.682,0 -105.145,47.464 -105.145,105.144c0,8.002 0.914,15.979 2.722,23.773c-84.418,-4.231 -163.18,-44.161 -216.494,-109.752c-27.724,47.726 -13.379,109.576 32.522,140.226c-16.715,-0.495 -33.071,-5.005 -47.677,-13.148l0,1.331c0.014,49.814 35.447,93.111 84.275,102.974c-15.464,4.217 -31.693,4.833 -47.431,1.802c13.727,42.685 53.311,72.108 98.14,72.95c-37.19,29.227 -83.157,45.103 -130.458,45.056c-8.358,-0.016 -16.708,-0.522 -25.006,-1.516c48.034,30.825 103.94,47.18 161.014,47.104" style="fill:#1da1f2;fill-rule:nonzero;"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -16,6 +16,10 @@ export const SettingsLayout: React.FC<{
type === "site"
? [
{ text: "General", href: `/dashboard/${subdomain}/settings/general` },
{
text: "Social Platforms",
href: `/dashboard/${subdomain}/settings/social-platforms`,
},
{
text: "Navigation",
href: `/dashboard/${subdomain}/settings/navigation`,
+20
View File
@@ -0,0 +1,20 @@
import React from "react"
export const PlanetIcon: React.FC<React.ComponentPropsWithoutRef<"svg">> = (
props,
) => {
return (
<svg
width="1em"
height="1em"
{...props}
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M16.4341517,5.34027649 C19.5526401,4.82550436 21.9775728,5.30066885 22.7613144,6.98140814 C23.5450164,8.66206251 22.3504571,10.824965 19.951836,12.8828831 C19.5123956,16.8857302 16.1198862,20 12,20 C10.359675,20 8.83465517,19.5063199 7.56541555,18.6594348 C4.44608523,19.1746732 2.02039254,18.6996452 1.23650448,17.0185919 C0.452540248,15.3373751 1.64816139,13.1735876 4.04839101,11.1150512 C4.48877158,7.11319839 7.88082257,4 12,4 C13.6401386,4 15.1649982,4.49356789 16.4341517,5.34027649 Z M18.3526801,7.13687265 C19.0478987,8.04366602 19.553342,9.10361155 19.8096504,10.2573495 C20.759634,9.23569807 21.1931253,8.35081879 20.9486988,7.82664467 C20.7041658,7.30224176 19.7469377,7.06554811 18.3526801,7.13687265 Z M5.64723739,16.8630198 C4.95168113,15.9557542 4.44609504,14.8951833 4.1899293,13.7407574 C3.23872065,14.7632088 2.80454268,15.6488575 3.04912005,16.1733553 C3.29377581,16.6980213 4.25184178,16.9346893 5.64723739,16.8630198 Z M17.998801,11.8788388 C17.9342721,8.62105818 15.2732265,6 12,6 C8.6862915,6 6,8.6862915 6,12 C6,13.8017545 6.79417414,15.4180196 8.05156374,16.5178367 C9.61918795,16.1740501 11.4219878,15.5791568 13.2667642,14.7189234 C15.1123744,13.8583012 16.727532,12.8591526 17.998801,11.8788388 Z M17.3040733,14.8073455 C16.3274273,15.4175193 15.2552552,15.9984306 14.1120008,16.5315389 C12.9695057,17.0642931 11.8360704,17.5119809 10.7415499,17.8678087 C11.1473536,17.9544194 11.5683538,18 12,18 C14.2994717,18 16.2968203,16.7064576 17.3040733,14.8073455 Z"
fill-rule="evenodd"
/>
</svg>
)
}
+106
View File
@@ -0,0 +1,106 @@
import { Image } from "~/components/ui/Image"
import { UniLink } from "~/components/ui/UniLink"
import { PlanetIcon } from "~/components/icons/PlanetIcon"
import { Tooltip } from "~/components/ui/Tooltip"
import clsx from "clsx"
const syncMap: {
[key: string]: {
name: string
icon: string
url?: string
}
} = {
telegram: {
name: "Telegram",
icon: "/assets/social/telegram.svg",
url: "https://t.me/{username}",
},
tg_channel: {
name: "Telegram Channel",
icon: "/assets/social/telegram.svg",
url: "https://t.me/{username}",
},
twitter: {
name: "Twitter",
icon: "/assets/social/twitter.svg",
url: "https://twitter.com/{username}",
},
twitter_id: {
name: "Twitter",
icon: "/assets/social/twitter.svg",
url: "https://twitter.com/i/user/{username}",
},
pixiv: {
name: "Pixiv",
icon: "/assets/social/pixiv.ico",
url: "https://www.pixiv.net/users/{username}",
},
substack: {
name: "Substack",
icon: "/assets/social/substack.svg",
url: "https://{username}.substack.com/",
},
medium: {
name: "Mediam",
icon: "/assets/social/medium.svg",
url: "https://medium.com/@{username}",
},
github: {
name: "GitHub",
icon: "/assets/social/github.svg",
url: "https://github.com/{username}",
},
jike: {
name: "Jike",
icon: "/assets/social/jike.png",
url: "https://web.okjike.com/u/{username}",
},
bilibili: {
name: "bilibili",
icon: "/assets/social/bilibili.svg",
url: "https://space.bilibili.com/{username}",
},
playstation: {
name: "PlayStation",
icon: "/assets/social/playstation.svg",
url: "https://psnprofiles.com/{username}",
},
"nintendo switch": {
name: "Nintendo Switch",
icon: "/assets/social/nintendo_switch.svg",
},
}
export const Platform: React.FC<{
platform: string
username: string
className?: string
}> = ({ platform, username, className }) => {
platform = platform.toLowerCase()
return (
<UniLink
className={clsx(
"inline-flex hover:scale-110 transition-transform ease align-middle",
className,
)}
key={platform}
href={syncMap[platform]?.url?.replace("{username}", username)}
>
<Tooltip
label={`${syncMap[platform]?.name || platform}: ${username}`}
className="capitalize"
>
<span className="w-6 h-6 inline-block overflow-hidden">
{syncMap[platform]?.icon ? (
<Image fill src={syncMap[platform]?.icon} alt={platform} />
) : (
<span className="rounded-md inline-flex fill-white justify-center items-center bg-zinc-300 w-6 h-6">
<PlanetIcon className="w-5 h-5" />
</span>
)}
</span>
</Tooltip>
</UniLink>
)
}
+15 -2
View File
@@ -3,6 +3,7 @@ import { UniLink } from "../ui/UniLink"
import { Profile, Note } from "~/lib/types"
import Script from "next/script"
import Image from "next/image"
import { Platform } from "~/components/site/Platform"
export const SiteFooter: React.FC<{
site?: Profile | null
@@ -11,11 +12,11 @@ export const SiteFooter: React.FC<{
return (
<>
<footer className="text-zinc-500 border-t">
<div className="max-w-screen-md mx-auto px-5 py-10 text-xs">
<div className="max-w-screen-md mx-auto px-5 py-10 text-xs flex justify-between">
<p className="font-medium text-base">
&copy;{" "}
<UniLink href="/" className="hover:text-accent">
{site?.username}
{site?.name}
</UniLink>{" "}
· Powered by{" "}
<UniLink
@@ -30,6 +31,18 @@ export const SiteFooter: React.FC<{
/>
</UniLink>
</p>
{site?.connected_accounts && (
<div className="ml-5 -mr-5">
{site?.connected_accounts.map((account, index) => (
<Platform
key={index}
platform={account.platform}
username={account.identity}
className="mr-2 sm:mr-5"
></Platform>
))}
</div>
)}
</div>
</footer>
{site?.ga && (
+12 -2
View File
@@ -13,14 +13,21 @@ import {
useDismiss,
useTransitionStyles,
} from "@floating-ui/react"
import clsx from "clsx"
interface Props {
label: string
placement?: Placement
children: JSX.Element
className?: string
}
export const Tooltip = ({ children, label, placement = "top" }: Props) => {
export const Tooltip = ({
children,
label,
placement = "top",
className,
}: Props) => {
const [open, setOpen] = useState(false)
const { x, y, refs, strategy, context } = useFloating({
@@ -54,7 +61,10 @@ export const Tooltip = ({ children, label, placement = "top" }: Props) => {
{isMounted && (
<div
ref={refs.setFloating}
className="bg-zinc-600 text-white rounded-lg shadow-lg px-3 py-1"
className={clsx(
"bg-zinc-600 text-white rounded-lg shadow-lg px-3 py-1 whitespace-nowrap",
className,
)}
style={{
position: strategy,
top: y ?? "0",
+4
View File
@@ -275,6 +275,7 @@ export async function updateSite(
address: string
mime_type: string
}
connected_accounts?: Profile["connected_accounts"]
},
customUnidata?: Unidata,
newbieToken?: string,
@@ -292,6 +293,9 @@ export async function updateSite(
...(payload.icon && { avatars: [payload.icon] }),
...(payload.banner && { banners: [payload.banner] }),
...(payload.subdomain && { username: payload.subdomain }),
...(payload.connected_accounts && {
connected_accounts: payload.connected_accounts,
}),
...((payload.navigation !== undefined ||
payload.css !== undefined ||
payload.ga !== undefined ||
@@ -0,0 +1,211 @@
import { Button } from "~/components/ui/Button"
import { Input } from "~/components/ui/Input"
import { ChangeEvent, FormEvent, useEffect, useMemo, useState } from "react"
import toast from "react-hot-toast"
import { SettingsLayout } from "~/components/dashboard/SettingsLayout"
import { useRouter } from "next/router"
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
import { Profile } from "~/lib/types"
import { nanoid } from "nanoid"
import { ReactSortable } from "react-sortablejs"
import equal from "fast-deep-equal"
import { useGetSite, useUpdateSite } from "~/queries/site"
import type { ReactElement } from "react"
import { UniLink } from "~/components/ui/UniLink"
import { Platform } from "~/components/site/Platform"
type Item = Required<Profile>["connected_accounts"][number] & {
id: string
}
type UpdateItem = (id: string, newItem: Partial<Item>) => void
type RemoveItem = (id: string) => void
const SortableNavigationItem: React.FC<{
item: Item
updateItem: UpdateItem
removeItem: RemoveItem
}> = ({ item, updateItem, removeItem }) => {
return (
<div className="flex space-x-5 border-b p-5 bg-zinc-50 last:border-0">
<div>
<button
type="button"
className="drag-handle cursor-grab -mt-1 text-zinc-400 rounded-lg h-8 w-6 flex items-center justify-center hover:text-zinc-800 hover:bg-zinc-200"
>
<svg className="w-5 h-8" viewBox="0 0 24 24">
<path
fill="currentColor"
d="M9 20q-.825 0-1.412-.587Q7 18.825 7 18q0-.825.588-1.413Q8.175 16 9 16t1.413.587Q11 17.175 11 18q0 .825-.587 1.413Q9.825 20 9 20Zm0-6q-.825 0-1.412-.588Q7 12.825 7 12t.588-1.413Q8.175 10 9 10t1.413.587Q11 11.175 11 12q0 .825-.587 1.412Q9.825 14 9 14Zm0-6q-.825 0-1.412-.588Q7 6.825 7 6t.588-1.412Q8.175 4 9 4t1.413.588Q11 5.175 11 6t-.587 1.412Q9.825 8 9 8Zm6 0q-.825 0-1.412-.588Q13 6.825 13 6t.588-1.412Q14.175 4 15 4t1.413.588Q17 5.175 17 6t-.587 1.412Q15.825 8 15 8Zm0 6q-.825 0-1.412-.588Q13 12.825 13 12t.588-1.413Q14.175 10 15 10t1.413.587Q17 11.175 17 12q0 .825-.587 1.412Q15.825 14 15 14Zm0 6q-.825 0-1.412-.587Q13 18.825 13 18q0-.825.588-1.413Q14.175 16 15 16t1.413.587Q17 17.175 17 18q0 .825-.587 1.413Q15.825 20 15 20Z"
></path>
</svg>
</button>
</div>
<Input
label="Platform"
required
id={`${item.id}-platform`}
value={item.platform}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
updateItem(item.id, { platform: e.target.value })
}
/>
<Input
label="Identity"
required
id={`${item.id}-identity`}
type="text"
value={item.identity}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
updateItem(item.id, { identity: e.target.value })
}
/>
<div className="flex items-end pb-2">
<Platform platform={item.platform} username={item.identity}></Platform>
</div>
<div className="flex items-end relative -top-[5px]">
<Button onClick={() => removeItem(item.id)} variantColor="red">
Remove
</Button>
</div>
</div>
)
}
export default function SiteSettingsNavigationPage() {
const router = useRouter()
const subdomain = router.query.subdomain as string
const updateSite = useUpdateSite()
const site = useGetSite(subdomain)
const [items, setItems] = useState<Item[]>([])
const itemsModified = useMemo(() => {
if (!site.isSuccess) return false
return !equal(items, site.data?.connected_accounts)
}, [items, site.data, site.isSuccess])
const updateItem: UpdateItem = (id, newItem) => {
setItems((items) => {
return items.map((item) => {
if (item.id === id) {
return { ...item, ...newItem }
}
return item
})
})
}
const newEmptyItem = () => {
setItems((items) => [
...items,
{ id: nanoid(), platform: "", identity: "" },
])
}
const handleSubmit = (e: FormEvent<HTMLFormElement>) => {
e.preventDefault()
updateSite.mutate({
site: site.data?.username!,
connected_accounts: items.map(({ id, ...item }) => item),
})
}
useEffect(() => {
if (updateSite.isSuccess) {
if (updateSite.data?.code === 0) {
toast.success("Saved")
} else {
toast.error("Failed to save" + ": " + updateSite.data.message)
}
} else if (updateSite.isError) {
toast.error("Failed to save")
}
}, [updateSite.isSuccess, updateSite.isError])
const removeItem: RemoveItem = (id) => {
setItems((items) => items.filter((item) => item.id !== id))
}
const [hasSet, setHasSet] = useState(false)
useEffect(() => {
if (site.data?.connected_accounts && !hasSet) {
setHasSet(true)
setItems(
site.data?.connected_accounts.map((item) => ({
id: nanoid(),
...item,
})),
)
}
}, [site.data?.connected_accounts, hasSet])
return (
<SettingsLayout title="Site Settings" type="site">
<div className="p-5 text-zinc-500 bg-zinc-50 mb-5 rounded-lg text-xs space-y-2">
<p className="text-zinc-800 text-sm font-bold">Tips:</p>
<p>
<span className="text-zinc-800">
These social platforms will be displayed in the bottom right hand
corner of your xLog.
</span>
</p>
<p>
<span className="text-zinc-800">
You can also connect to Twitter, Telegram Channel, Medium, Substack
and more and automatically sync content on{" "}
<UniLink href="https://xsync.app/" className="underline">
xSync
</UniLink>
. When you have set up the sync there, it will also show here.
</span>
</p>
</div>
<form onSubmit={handleSubmit}>
<div className="bg-zinc-50 rounded-lg overflow-hidden">
{items.length === 0 && (
<div className="text-center text-zinc-500 p-5">
No navigation items yet
</div>
)}
<ReactSortable list={items} setList={setItems} handle=".drag-handle">
{items.map((item) => {
return (
<SortableNavigationItem
key={item.id}
item={item}
updateItem={updateItem}
removeItem={removeItem}
/>
)
})}
<style jsx global>{`
.sortable-ghost {
opacity: 0.4;
}
`}</style>
</ReactSortable>
</div>
<div className="border-t pt-5 mt-10 space-x-3 flex items-center">
<Button
type="submit"
isLoading={updateSite.isLoading}
isDisabled={!itemsModified}
>
Save
</Button>
<Button variant="secondary" onClick={newEmptyItem}>
New Item
</Button>
</div>
</form>
</SettingsLayout>
)
}
SiteSettingsNavigationPage.getLayout = (page: ReactElement) => {
return <DashboardLayout title="Site Settings">{page}</DashboardLayout>
}