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

Styling Fixes #51

Merged
merged 7 commits into from
May 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/big-bears-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'docusaurus-theme-redoc': patch
---

Fix styling issues in schema definitions and code samples - #13 #45 #47
5 changes: 5 additions & 0 deletions .changeset/spotty-weeks-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'docusaurus-plugin-redoc': patch
---

Add watch mode support for YAML files
1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"author": "Rohit Gohri <[email protected]>",
"scripts": {
"clear": "docusaurus clear",
"dev": "docusaurus start",
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
"build": "lerna run build --ignore 'redocusaurus-example'",
"build:example": "lerna run build --scope 'redocusaurus-example'",
"clean": "lerna exec -- \"rm -rf dist* .tsbuild*.info\"",
"dev": "lerna run --parallel dev",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"test": "echo \"Error: no test specified\" && exit 1",
"release": "yarn build && changeset publish"
"lint:fix": "yarn lint --fix",
"release": "yarn build && changeset publish",
"start": "yarn build && lerna run start --stream --scope redocusaurus-example",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -39,6 +42,7 @@
"@types/react": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^4.16.1",
"@typescript-eslint/parser": "^4.16.1",
"concurrently": "^6.2.0",
"eslint": "^7.23.0",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-config-prettier": "^8.1.0",
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-redoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"dev": "tsc -w",
"prepublish": "rm -rf .tsbuild.info",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
12 changes: 10 additions & 2 deletions packages/docusaurus-plugin-redoc/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'fs';
import path from 'path';
import type {
LoadContext,
Plugin,
Expand Down Expand Up @@ -44,6 +45,13 @@ export default function redocPlugin(
}
return content;
},
getPathsToWatch() {
if (!spec) {
return [];
}
const contentPath = path.resolve(context.siteDir, spec);
return [contentPath];
},
async contentLoaded({ content, actions }) {
const { createData, addRoute } = actions;
if (!content && !specUrl) {
Expand All @@ -62,11 +70,11 @@ export default function redocPlugin(
JSON.stringify(options.layout),
);

const path = options.routePath.startsWith('/')
const routePath = options.routePath.startsWith('/')
? options.routePath.slice(1)
: options.routePath;
const routeOptions = {
path: normalizeUrl([baseUrl, path]),
path: normalizeUrl([baseUrl, routePath]),
component: options.apiDocComponent,
modules: {
spec: specData,
Expand Down
5 changes: 4 additions & 1 deletion packages/docusaurus-theme-redoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
"main": "dist/index.js",
"scripts": {
"_copy": "npx copyup -e \"./**/*.jsx\" -e \"./**/*.js\" -e \"./**/*.ts\" -e \"./**/*.tsx\" \"./src/**/*.*\"",
"copy": "yarn _copy ./dist && yarn _copy ./dist-jsx",
"copy:watch": "nodemon --watch ./src/**/*.css -e css --exec \"yarn copy\"",
"build": "tsc -p tsconfig.jsx.json && tsc",
"postbuild": "yarn _copy ./dist && yarn _copy ./dist-jsx",
"postbuild": "yarn copy",
"dev": "concurrently 'tsc -w -p tsconfig.jsx.json' 'tsc -w' 'yarn copy:watch'",
"prepublish": "rm -rf rm .tsbuild.info .tsbuild.jsx.info",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
47 changes: 42 additions & 5 deletions packages/docusaurus-theme-redoc/src/theme/Redoc/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ html[data-theme='dark'] .redocusaurus h2 > a:nth-child(1)::before {
/* ------- Right Panel Overrides ------- */

.redocusaurus code {
color: var(--ifm-color-emphasis-900);
padding: 0px;
/* Fix weird overlay on curly braces */
background-color: transparent;
}

/** https://github.com/rohit-gohri/redocusaurus/issues/45 */
html:not([data-theme='dark']) .redocusaurus code {
color: var(--ifm-color-emphasis-0);
}

.redocusaurus
ul
> li.react-tabs__tab--selected:not(.tab-error):not(.tab-success) {
Expand Down Expand Up @@ -124,15 +128,48 @@ html:not([data-theme='dark'])

/* ------ Schema Styling Overrides ------- */

.redocusaurus table th,
.redocusaurus table td {
.redocusaurus table th {
border: none;
}

.redocusaurus table > tbody > tr {
color: var(--ifm-font-color);
.redocusaurus table td {
border-top: none;
border-right: none;
}

.redocusaurus table td:nth-child(1) {
border-bottom: none;
}

.redocusaurus table td:nth-child(2) {
border-left: none;
}

.redocusaurus table tr {
background-color: var(--ifm-background-color);
}

.redocusaurus table > tbody > tr {
color: var(--ifm-font-color-base);
}

.redocusaurus table tbody tr table {
background-color: var(--ifm-background-surface-color);
}

.redocusaurus table tbody tr table tbody tr {
background-color: var(--ifm-background-surface-color);
}

.redocusaurus tr.last + tr > td > div {
background-color: var(--ifm-background-color) !important;
}

.redocusaurus span.dropdown-selector-value {
color: var(--ifm-font-color-secondary);
}

/* Authentication tables */
.redocusaurus table.security-details tr:nth-child(2n + 1) {
background-color: var(--ifm-background-surface-color);
}
1 change: 1 addition & 0 deletions packages/redocusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"scripts": {
"build": "tsc",
"dev": "tsc -w",
"prepublish": "rm -rf .tsbuild.info",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
37 changes: 37 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4761,6 +4761,21 @@ concat-stream@^2.0.0:
readable-stream "^3.0.2"
typedarray "^0.0.6"

concurrently@^6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-6.2.0.tgz#587e2cb8afca7234172d8ea55176088632c4c56d"
integrity sha512-v9I4Y3wFoXCSY2L73yYgwA9ESrQMpRn80jMcqMgHx720Hecz2GZAvTI6bREVST6lkddNypDKRN22qhK0X8Y00g==
dependencies:
chalk "^4.1.0"
date-fns "^2.16.1"
lodash "^4.17.21"
read-pkg "^5.2.0"
rxjs "^6.6.3"
spawn-command "^0.0.2-1"
supports-color "^8.1.0"
tree-kill "^1.2.2"
yargs "^16.2.0"

config-chain@^1.1.12:
version "1.1.12"
resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.12.tgz#0fde8d091200eb5e808caf25fe618c02f48e4efa"
Expand Down Expand Up @@ -5354,6 +5369,11 @@ dataloader@^1.4.0:
resolved "https://registry.yarnpkg.com/dataloader/-/dataloader-1.4.0.tgz#bca11d867f5d3f1b9ed9f737bd15970c65dff5c8"
integrity sha512-68s5jYdlvasItOJnCuI2Q9s4q98g0pCyL3HrcKJu8KNugUl8ahgmZYg38ysLTgQjjXX3H8CJLkAvWrclWfcalw==

date-fns@^2.16.1:
version "2.22.1"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.22.1.tgz#1e5af959831ebb1d82992bf67b765052d8f0efc4"
integrity sha512-yUFPQjrxEmIsMqlHhAhmxkuH769baF21Kk+nZwZGyrMoyLA+LugaQtC0+Tqf9CBUUULWwUJt6Q5ySI3LJDDCGg==

dateformat@^3.0.0:
version "3.0.3"
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
Expand Down Expand Up @@ -12651,6 +12671,11 @@ space-separated-tokens@^1.0.0:
resolved "https://registry.yarnpkg.com/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz#85f32c3d10d9682007e917414ddc5c26d1aa6899"
integrity sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA==

spawn-command@^0.0.2-1:
version "0.0.2-1"
resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0"
integrity sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A=

spawndamnit@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/spawndamnit/-/spawndamnit-2.0.0.tgz#9f762ac5c3476abb994b42ad592b5ad22bb4b0ad"
Expand Down Expand Up @@ -13068,6 +13093,13 @@ supports-color@^7.0.0, supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"

supports-color@^8.1.0:
version "8.1.1"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c"
integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==
dependencies:
has-flag "^4.0.0"

svg-parser@^2.0.2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/svg-parser/-/svg-parser-2.0.4.tgz#fdc2e29e13951736140b76cb122c8ee6630eb6b5"
Expand Down Expand Up @@ -13368,6 +13400,11 @@ tr46@^2.0.2:
dependencies:
punycode "^2.1.1"

tree-kill@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc"
integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==

trim-newlines@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"
Expand Down