Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
breadchris committed Feb 8, 2024
1 parent e912084 commit 41733f6
Show file tree
Hide file tree
Showing 11 changed files with 447 additions and 324 deletions.
60 changes: 55 additions & 5 deletions js/dist/extension/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,36 @@ html {
color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity)));
}

.btm-nav {
position: fixed;
bottom: 0px;
left: 0px;
right: 0px;
display: flex;
width: 100%;
flex-direction: row;
align-items: center;
justify-content: space-around;
padding-bottom: env(safe-area-inset-bottom);
height: 4rem;
--tw-bg-opacity: 1;
background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity)));
color: currentColor;
}

.btm-nav > * {
position: relative;
display: flex;
height: 100%;
flex-basis: 100%;
cursor: pointer;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0.25rem;
border-color: currentColor;
}

@media (hover:hover) {
.checkbox-accent:hover {
--tw-border-opacity: 1;
Expand Down Expand Up @@ -2492,6 +2522,10 @@ input.tab:checked + .tab-content,
color: var(--fallback-er,oklch(var(--er)/var(--tw-text-opacity)));
}

.btm-nav > *:not(.active) {
padding-top: 0.125rem;
}

.btm-nav > *:where(.active) {
border-top-width: 2px;
--tw-bg-opacity: 1;
Expand All @@ -2508,16 +2542,16 @@ input.tab:checked + .tab-content,
--tw-text-opacity: 0.2;
}

.btm-nav > * .\!label {
font-size: 1rem !important;
line-height: 1.5rem !important;
}

.btm-nav > * .label {
font-size: 1rem;
line-height: 1.5rem;
}

.btm-nav > * .\!label {
font-size: 1rem !important;
line-height: 1.5rem !important;
}

.btn:active:hover,
.btn:active:focus {
animation: button-pop 0s ease-out;
Expand Down Expand Up @@ -5060,6 +5094,10 @@ details.collapse summary::-webkit-details-marker {
margin-bottom: 1.5rem;
}

.mb-16 {
margin-bottom: 4rem;
}

.mb-4 {
margin-bottom: 1rem;
}
Expand Down Expand Up @@ -5614,7 +5652,19 @@ details.collapse summary::-webkit-details-marker {
a: a;
}

@media (min-width: 640px) {
.sm\:mx-4 {
margin-left: 1rem;
margin-right: 1rem;
}
}

@media (min-width: 1024px) {
.lg\:mx-16 {
margin-left: 4rem;
margin-right: 4rem;
}

.lg\:mx-\[6vw\] {
margin-left: 6vw;
margin-right: 6vw;
Expand Down
108 changes: 54 additions & 54 deletions js/dist/site/index.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions js/dist/site/index.js.map

Large diffs are not rendered by default.

60 changes: 55 additions & 5 deletions js/dist/site/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,36 @@ html {
color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity)));
}

.btm-nav {
position: fixed;
bottom: 0px;
left: 0px;
right: 0px;
display: flex;
width: 100%;
flex-direction: row;
align-items: center;
justify-content: space-around;
padding-bottom: env(safe-area-inset-bottom);
height: 4rem;
--tw-bg-opacity: 1;
background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity)));
color: currentColor;
}

.btm-nav > * {
position: relative;
display: flex;
height: 100%;
flex-basis: 100%;
cursor: pointer;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0.25rem;
border-color: currentColor;
}

@media (hover:hover) {
.checkbox-accent:hover {
--tw-border-opacity: 1;
Expand Down Expand Up @@ -2492,6 +2522,10 @@ input.tab:checked + .tab-content,
color: var(--fallback-er,oklch(var(--er)/var(--tw-text-opacity)));
}

.btm-nav > *:not(.active) {
padding-top: 0.125rem;
}

.btm-nav > *:where(.active) {
border-top-width: 2px;
--tw-bg-opacity: 1;
Expand All @@ -2508,16 +2542,16 @@ input.tab:checked + .tab-content,
--tw-text-opacity: 0.2;
}

.btm-nav > * .\!label {
font-size: 1rem !important;
line-height: 1.5rem !important;
}

.btm-nav > * .label {
font-size: 1rem;
line-height: 1.5rem;
}

.btm-nav > * .\!label {
font-size: 1rem !important;
line-height: 1.5rem !important;
}

.btn:active:hover,
.btn:active:focus {
animation: button-pop 0s ease-out;
Expand Down Expand Up @@ -5060,6 +5094,10 @@ details.collapse summary::-webkit-details-marker {
margin-bottom: 1.5rem;
}

.mb-16 {
margin-bottom: 4rem;
}

.mb-4 {
margin-bottom: 1rem;
}
Expand Down Expand Up @@ -5614,7 +5652,19 @@ details.collapse summary::-webkit-details-marker {
a: a;
}

@media (min-width: 640px) {
.sm\:mx-4 {
margin-left: 1rem;
margin-right: 1rem;
}
}

@media (min-width: 1024px) {
.lg\:mx-16 {
margin-left: 4rem;
margin-right: 4rem;
}

.lg\:mx-\[6vw\] {
margin-left: 6vw;
margin-right: 6vw;
Expand Down
141 changes: 141 additions & 0 deletions js/site/source/ContentDrawer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import React from "react";
import {useContentEditor, useSources} from "@/source/state";
import {ListBulletIcon, TrashIcon} from "@heroicons/react/24/outline";
import {AddTagBadge} from "@/tag/AddTagBadge";
import {Content, DisplayContent} from "@/rpc/content/content_pb";
import {contentService} from "@/service";
import toast from "react-hot-toast";
import {notEmpty} from "@/util/predicates";

export const ContentDrawer: React.FC<{}> = () => {
const {
selected,
setTypes,
setTags,
tags,
} = useSources();

const toggleType = (type: string) => async () => {
setTypes((types) => {
if (types.includes(type)) {
return types.filter((t) => t !== type);
}
return [...types, type];
});
}
return (
<div className="drawer z-50">
<input id="my-drawer" type="checkbox" className="drawer-toggle" />
<div className="drawer-content">
<label htmlFor="my-drawer" className="drawer-button">
<ListBulletIcon className="h-6 w-6" />
</label>
</div>
<div className="drawer-side">
<label htmlFor="my-drawer" aria-label="close sidebar" className="drawer-overlay"></label>
{selected && (
// <ContentCards displayContent={selected.displayContent} />
<div className={"flex flex-col p-4 w-80 min-h-full bg-base-200 text-base-content"}>
<div className={"flex flex-row space-y-2"}>
<div>
<details className={"dropdown"}>
<summary className={"btn"}>type</summary>
<ul className={"p-2 shadow menu dropdown-content z-[1] bg-base-100 rounded-box w-52"}>
<li onClick={toggleType('site')}>site</li>
<li onClick={toggleType('post')}>post</li>
</ul>
</details>
</div>
<AddTagBadge onNewTag={(t) => {
setTags((tags) => {
if (tags.includes(t)) {
return tags;
}
return [...tags, t];
});
}} />
{tags.map((tag) => (
<span key={tag} className="badge badge-outline badge-sm" onClick={() => {
setTags((tags) => tags.filter((t) => t !== tag));
}}>{tag}</span>
))}
</div>
<div className={"overflow-x-auto"}>
<ContentTable displayContent={selected.displayContent} />
</div>
</div>
)}
</div>
</div>
)
}

const ContentTable: React.FC<{displayContent: DisplayContent[]}> = ({displayContent}) => {
const {selectedContent, selectContent} = useContentEditor();
const { getSources } = useSources();
const handleCheckboxChange = (content: Content|undefined, isChecked: boolean) => {
if (isChecked && content) {
selectContent(content);
}
if (!isChecked) {
selectContent(undefined);
}
};

const handleDelete = async () => {
if (!selectedContent) {
return;
}
try {
// TODO breadchris save content to group
const resp = await contentService.delete({
contentIds: [selectedContent.id],
});
void getSources();
toast.success('Deleted content');
} catch (e) {
toast.error('Failed to delete content');
console.error('failed to delete', e)
}
}
const cnt = selectedContent ? [
displayContent.find((c) => c.content?.id === selectedContent.id),
...displayContent.filter((c) => c.content?.id !== selectedContent.id)
] : displayContent;
return (
<table className="table w-full">
<thead>
<tr>
<th>{selectedContent && (
<TrashIcon onClick={handleDelete} className="h-5 w-5" />
)}</th>
<th>title</th>
<th>tags</th>
</tr>
</thead>
<tbody>
{cnt.filter(notEmpty).map((item, index) => (
<tr key={index}>
<td>
<input
type="checkbox"
className="checkbox checkbox-accent"
checked={selectedContent?.id === item.content?.id}
onChange={(e) => handleCheckboxChange(item.content, e.target.checked)}
/>
</td>
<td>{item.title}</td>
<td>
<div className="gap-3">
{item.content?.tags.map((tag) => (
<span key={tag} className="badge badge-outline badge-sm">{tag}</span>
))}
</div>
</td>
</tr>
))}
</tbody>
</table>
);
}

Loading

0 comments on commit 41733f6

Please sign in to comment.