Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate flowershow packages #923

Merged
merged 33 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9ef5d52
[packages][m]: mv @flowershow/core package here
olayway May 26, 2023
772447d
[packages/core][xs]: rename to @portaljs/core
olayway Jun 5, 2023
e44e197
[package.json][xs]: setup npm workspaces
olayway Jun 5, 2023
9aaeb55
[packages/core][xs]:replace deprecated rollup executor
olayway Jun 5, 2023
af6957e
[core/package.json][s]: fix mermaid versions
olayway Jun 5, 2023
22b57ae
[core/tsconfig][xs]: rm extends
olayway Jun 5, 2023
b9d94df
[core/jest.config][xs]: rm coverageDirectory
olayway Jun 5, 2023
46017e4
[core/package.json][xs]: install core-js
olayway Jun 5, 2023
6b040b0
[packages.json][s]:use same version for all nrwl packages
olayway Jun 5, 2023
0710955
[core/.eslintrc][xs]: adjust ignorePatterns
olayway Jun 5, 2023
c61a2db
[core/project.json][xs]: rm publish targets
olayway Jun 6, 2023
ee68129
[packages][m]: mv @flowershow/remark-wiki-link here
olayway Jun 6, 2023
e32332a
[packages][m]: mv @flowershow/remark-wiki-link here
olayway Jun 6, 2023
395e072
[packages][m]: mv @flowershow/remark-embed here
olayway Jun 6, 2023
a02d9dc
[remark-callouts/project.json][xs]: adjst test pattern
olayway Jun 6, 2023
93f5316
[package.json][s]: install missing deps
olayway Jun 6, 2023
e25f1f2
[remark-callouts][xs]: adjst fields in package.json
olayway Jun 6, 2023
90d736a
[remark-callouts][s]: rm pubish targets and adjst build executor
olayway Jun 6, 2023
c02f7c4
[remark-embed/jest.config][xs]: rm unknown option coverageDirectory
olayway Jun 6, 2023
7303a49
[remark-embed][xs]: rm publish targets
olayway Jun 6, 2023
73d10e9
[remark-embed][s]: rename to @portaljs/remark-embed
olayway Jun 6, 2023
f6e7e1f
[remark-wiki-link/eslintrc][xs]:adjst ignorePatterns
olayway Jun 6, 2023
310a4cc
[package.json][xs]: install missing deps
olayway Jun 6, 2023
00166a5
[remark-wiki-link/test][xs]:specify format
olayway Jun 6, 2023
5e863e4
[remark-wiki-link/README][xs]: replace @flowershow with @portaljs
olayway Jun 6, 2023
a592048
[remark-wiki-link][xs]:rm old changelog
olayway Jun 6, 2023
5dbb4e5
[remark-wiki-link][xs]: adjst package.json
olayway Jun 6, 2023
113ab3c
[remark-wiki-link/project.json][xs]: rm publish targets
olayway Jun 6, 2023
18cfb41
[core][s]: rm old changelog
olayway Jun 6, 2023
975b4d8
[core/README][xs]:correct scope name
olayway Jun 6, 2023
c643e6b
[remark-callouts/README][xs]: add @portaljs to pckg name
olayway Jun 6, 2023
11b3056
[remark-embed/README][xs]: add @portaljs to pckg name
olayway Jun 6, 2023
dc4646b
[package-lock.json][xs]: refresh after rebasing on main
olayway Jun 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,798 changes: 4,475 additions & 2,323 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "portaljs",
"workspaces": ["./packages/*"],
"workspaces": [
"./packages/*"
],
"version": "0.0.0",
"license": "MIT",
"scripts": {
Expand All @@ -14,11 +16,11 @@
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.1",
"@nrwl/cypress": "15.9.2",
"@nrwl/eslint-plugin-nx": "^16.0.2",
"@nrwl/eslint-plugin-nx": "15.9.2",
"@nrwl/jest": "15.9.2",
"@nrwl/js": "15.9.2",
"@nrwl/linter": "15.9.2",
"@nrwl/next": "^15.9.2",
"@nrwl/next": "15.9.2",
"@nrwl/react": "15.9.2",
"@nrwl/rollup": "15.9.2",
"@nrwl/workspace": "15.9.2",
Expand All @@ -28,13 +30,16 @@
"@swc/helpers": "~0.5.0",
"@swc/jest": "0.2.20",
"@testing-library/react": "14.0.0",
"@types/chai": "^4.3.5",
"@types/jest": "^29.4.0",
"@types/mocha": "^10.0.1",
"@types/node": "18.14.2",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.11",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"babel-jest": "^29.4.1",
"chai": "^4.3.7",
"cypress": "^12.2.0",
"eslint": "~8.15.0",
"eslint-config-next": "13.1.1",
Expand All @@ -44,14 +49,21 @@
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-react-hooks": "4.6.0",
"htmlparser2": "^9.0.0",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"micromark": "^3.2.0",
"mocha": "^10.2.0",
"nx": "15.9.2",
"prettier": "^2.6.2",
"react-test-renderer": "18.2.0",
"rehype-stringify": "^9.0.3",
"remark": "^14.0.3",
"swc-loader": "0.1.15",
"ts-jest": "^29.0.5",
"ts-node": "10.9.1",
"typescript": "~4.9.5"
"typescript": "~4.9.5",
"unist-util-select": "^4.0.3",
"unist-util-visit": "^4.1.2"
}
}
12 changes: 12 additions & 0 deletions packages/core/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
18 changes: 18 additions & 0 deletions packages/core/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*", "dist/**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
3 changes: 3 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @portaljs/core

Core Portal.JS package containing components, styles, and utils.
9 changes: 9 additions & 0 deletions packages/core/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
export default {
displayName: "core",
preset: "../../jest.preset.js",
transform: {
"^.+\\.[tj]sx?$": "babel-jest",
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx"]
};
42 changes: 42 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@portaljs/core",
"version": "1.0.0",
"description": "Core Portal.JS components, configs and utils.",
"repository": {
"type": "git",
"url": "git+https://github.com/datopian/portaljs.git",
"directory": "packages/core"
},
"author": "Rufus Pollock",
"license": "MIT",
"bugs": {
"url": "https://github.com/datopian/portaljs/issues"
},
"homepage": "https://github.com/datopian/portaljs#readme",
"publishConfig": {
"access": "public"
},
"type": "module",
"main": "./dist/index.js",
"dependencies": {
"@docsearch/react": "^3.3.3",
"@floating-ui/react-dom": "^1.3.0",
"@floating-ui/react-dom-interactions": "^0.13.3",
"@giscus/react": "^2.2.6",
"@headlessui/react": "^1.7.12",
"clsx": "^1.2.1",
"core-js": "^3.30.2",
"disqus-react": "^1.1.5",
"framer-motion": "^10.0.1",
"kbar": "0.1.0-beta.40",
"mdx-mermaid": "^1.3.2",
"mermaid": "^10.2.2",
"prop-types": "^15.8.1"
},
"peerDependencies": {
"next": "^13.2.1",
"next-themes": "^0.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
45 changes: 45 additions & 0 deletions packages/core/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "core",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/core/src",
"projectType": "library",
"tags": [],
"targets": {
"build": {
"executor": "@nrwl/rollup:rollup",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "packages/core/dist",
"tsConfig": "packages/core/tsconfig.lib.json",
"project": "packages/core/package.json",
"entryFile": "packages/core/src/index.ts",
"format": ["esm"],
"generateExportsField": true,
"rollupConfig": "@nrwl/react/plugins/bundle-rollup",
"compiler": "babel",
"assets": [
{
"glob": "packages/core/README.md",
"input": ".",
"output": "."
}
]
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/core/**/*.{ts,tsx,js,jsx}"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/core/jest.config.ts",
"passWithNoTests": true
}
}
}
}
31 changes: 31 additions & 0 deletions packages/core/src/config/default.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export const defaultConfig = {
title: "Flowershow",
description: "",
showEditLink: false,
showToc: true,
showSidebar: false,
showLinkPreviews: true,
author: "",
authorLogo: "",
domain: "",
// Google analytics key e.g. G-XXXX
analytics: "",
// content source directory for markdown files
// DO NOT CHANGE THIS VALUE
// if you have your notes in another (external) directory,
// /content dir should be a symlink to that directory
content: "content",
avatarPlaceholder: "/_flowershow/avatarplaceholder.png",
contentExclude: [],
contentInclude: [],
blogDir: "blog",
peopleDir: "people",
// Theme
theme: {
default: "dark",
toggleIcon: "/_flowershow/theme-button.svg",
},
navLinks: [
// { href: '/about', name: 'About' },
],
};
1 change: 1 addition & 0 deletions packages/core/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { defaultConfig } from "./default";
3 changes: 3 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./ui";
export * from "./utils";
export * from "./config";
7 changes: 7 additions & 0 deletions packages/core/src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export {};

declare global {
interface Window {
gtag: any; // TODO
}
}
24 changes: 24 additions & 0 deletions packages/core/src/ui/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// TODO
type Props = any;

export const Avatar: React.FC<Props> = ({ name, img, href }) => {
const Component = href ? "a" : "div";
return (
<Component href={href} className="group block flex-shrink-0 mt-2">
<div className="flex items-center space-x-2">
<div>
<img
className="inline-block h-9 w-9 rounded-full"
src={img}
alt={name}
/>
</div>
<div className="ml-3">
<p className="text-sm font-medium text-primary dark:text-primary-dark">
{name}
</p>
</div>
</div>
</Component>
);
};
1 change: 1 addition & 0 deletions packages/core/src/ui/Avatar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Avatar } from "./Avatar";
15 changes: 15 additions & 0 deletions packages/core/src/ui/Base/BaseLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Link from "next/link.js";
import { forwardRef } from "react";

const BaseLink = forwardRef((props: any, ref) => {
const { href, children, ...rest } = props;
return (
<Link href={href} ref={ref} {...rest}>
{children}
</Link>
);
});

BaseLink.displayName = "BaseLink";

export { BaseLink };
57 changes: 57 additions & 0 deletions packages/core/src/ui/Base/CustomLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import Link from "next/link.js";
import { Tooltip } from "../Tooltip";
import TwitterEmbed from "./TwitterEmbed";

// TODO it's a mess, move twitter embeds support to remark-embed
const TWITTER_REGEX =
/^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)/;

interface Props {
href: string;
data: any;
usehook: any;
preview: boolean;
children: React.ReactNode;
className?: string;
[x: string]: unknown;
}

export const CustomLink: React.FC<Props> = ({
data,
usehook,
preview,
...props
}) => {
const { href } = props;
const isInternalLink = !href.startsWith("http");
// eslint-disable-next-line no-useless-escape
const isHeadingLink = href.startsWith("#");
const isTwitterLink = TWITTER_REGEX.test(href);

// Use next link for pages within app and <a> for external links.
// https://nextjs.org/learn/basics/navigate-between-pages/client-side
if (isInternalLink) {
if (preview && !isHeadingLink) {
return (
<Tooltip
{...props}
data={data} // TODO again, why do we pass all documents here?!
usehook={usehook}
render={(tooltipTriggerProps) => <Link {...tooltipTriggerProps} />}
/>
);
} else {
return <Link {...props} />;
}
}

if (isTwitterLink) {
return <TwitterEmbed url={href} {...props} />;
}

return (
<a target="_blank" rel="noopener noreferrer" {...props}>
{props.children}
</a>
);
};
44 changes: 44 additions & 0 deletions packages/core/src/ui/Base/ThemeSelector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { useTheme } from "next-themes";
import { useEffect, useState } from "react";

interface Props {
defaultTheme: "dark" | "light";
toggleIcon: string;
}

export const ThemeSelector: React.FC<Props> = ({
defaultTheme,
toggleIcon,
}) => {
const [mounted, setMounted] = useState(false);
const { theme, setTheme } = useTheme();

useEffect(() => setMounted(true), []);

/** Avoid Hydration Mismatch
* https://github.com/pacocoursey/next-themes#avoid-hydration-mismatch
*/
if (!mounted) return null;

// TODO why?
if (!defaultTheme) return null;

return (
<button
type="button"
className={`
min-w-fit transition duration-500
${theme === "dark" ? "grayscale opacity-70" : ""}
`}
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
>
<img
src={toggleIcon}
alt="toggle theme"
width={24}
height={24}
className="max-w-24 max-h-24"
/>
</button>
);
};
Loading