Replaced Button components representing Tags with reusable Tag component
This commit is contained in:
@ -3,6 +3,7 @@ import { Row, Col, Form, Button } from "../external";
|
|||||||
import DateTimeHelper from "../../utils/dateTimeHelper";
|
import DateTimeHelper from "../../utils/dateTimeHelper";
|
||||||
import "../../styles/component/bookmark.css";
|
import "../../styles/component/bookmark.css";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { Tag } from "../../components";
|
||||||
|
|
||||||
export function Bookmark(props) {
|
export function Bookmark(props) {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@ -16,9 +17,9 @@ export function Bookmark(props) {
|
|||||||
<a href="#" style={{textDecoration: "none"}}>{props.bookmark.title}</a>
|
<a href="#" style={{textDecoration: "none"}}>{props.bookmark.title}</a>
|
||||||
<div className="font-weight-normal">{props.bookmark.description.substring(0, 100)}</div>
|
<div className="font-weight-normal">{props.bookmark.description.substring(0, 100)}</div>
|
||||||
<div>
|
<div>
|
||||||
{props.bookmark.tags.map((tag) => {
|
{
|
||||||
return <Button variant="link" key={props.bookmark.id-tag.id} style={{textDecoration: "none"}} className="p-0 me-2">#{tag.name}</Button>
|
props.bookmark.tags.map((tag) => <Tag key={props.bookmark.id-tag.id} tag={tag} />)
|
||||||
})}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span>{DateTimeHelper.getFriendlyDate(props.bookmark.createdOn)} | </span>
|
<span>{DateTimeHelper.getFriendlyDate(props.bookmark.createdOn)} | </span>
|
||||||
@ -1,12 +1,13 @@
|
|||||||
import { Footer } from "./footer";
|
import { Footer } from "./footer";
|
||||||
import { Header } from "./header";
|
import { Header } from "./header";
|
||||||
import { Bookmark } from "./bookmark/bookmark";
|
import { Bookmark } from "./bookmarks/bookmark";
|
||||||
import { Auth0ProviderWithNavigate } from "./auth0ProviderWithNavigate";
|
import { Auth0ProviderWithNavigate } from "./auth0ProviderWithNavigate";
|
||||||
import { ProtectedRoute } from "./protectedRoute";
|
import { ProtectedRoute } from "./protectedRoute";
|
||||||
import { SplashScreen } from "./shared/splashScreen";
|
import { SplashScreen } from "./shared/splashScreen";
|
||||||
import { SearchForm } from "./shared/searchForm";
|
import { SearchForm } from "./shared/searchForm";
|
||||||
import { UpsertTagModal } from "./tags/upsertTagModal";
|
import { UpsertTagModal } from "./tags/upsertTagModal";
|
||||||
import { InterceptModal } from "./shared/interceptModal";
|
import { InterceptModal } from "./shared/interceptModal";
|
||||||
|
import { Tag } from "./tags/tag";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Footer,
|
Footer,
|
||||||
@ -18,4 +19,5 @@ export {
|
|||||||
SearchForm,
|
SearchForm,
|
||||||
UpsertTagModal,
|
UpsertTagModal,
|
||||||
InterceptModal,
|
InterceptModal,
|
||||||
|
Tag,
|
||||||
};
|
};
|
||||||
13
yaba-web/src/components/tags/tag.jsx
Normal file
13
yaba-web/src/components/tags/tag.jsx
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { Button } from "../external";
|
||||||
|
|
||||||
|
export function Tag(props) {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant="link"
|
||||||
|
style={{textDecoration: "none"}} className={`ms-0 me-2 p-0 ${props.tag.isHidden ? "text-danger" : null}`}
|
||||||
|
onClick={props.onClick}>
|
||||||
|
#{props.tag.name}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
};
|
||||||
@ -3,7 +3,7 @@ import { Alert, Col, Container, Row, Button, Modal, Dropdown, DropdownButton } f
|
|||||||
import { Bookmark } from "../components";
|
import { Bookmark } from "../components";
|
||||||
import { useAuth0 } from "@auth0/auth0-react";
|
import { useAuth0 } from "@auth0/auth0-react";
|
||||||
import { deleteBookmarks, getAllBookmarks, hideBookmarks } from "../api";
|
import { deleteBookmarks, getAllBookmarks, hideBookmarks } from "../api";
|
||||||
import { SplashScreen, SearchForm } from "../components";
|
import { SplashScreen, SearchForm, Tag } from "../components";
|
||||||
import { getTagGroups, isSubset, containsSubstring, flattenTagArrays } from "../utils";
|
import { getTagGroups, isSubset, containsSubstring, flattenTagArrays } from "../utils";
|
||||||
|
|
||||||
export function BookmarksListView(props) {
|
export function BookmarksListView(props) {
|
||||||
@ -334,11 +334,7 @@ export function BookmarksListView(props) {
|
|||||||
<span key={group.name} className="text-primary fw-bold">{group.name}</span>
|
<span key={group.name} className="text-primary fw-bold">{group.name}</span>
|
||||||
<br />
|
<br />
|
||||||
{
|
{
|
||||||
group.tags.map((tag) => {
|
group.tags.map((tag) => <Tag key={tag.id} tag={tag} onClick={() => onTagSelected(true, tag)} />)
|
||||||
return <Button key={tag.id} variant="link" style={{textDecoration: "none"}} className={`ms-0 me-2 p-0 ${tag.isHidden ? "text-danger" : null}`} onClick={() => onTagSelected(true, tag)}>
|
|
||||||
#{tag.name}
|
|
||||||
</Button>
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user