Skip to content

Commit

Permalink
Merge pull request #92 from mtmacdonald/styles-cleanup
Browse files Browse the repository at this point in the history
Styles Cleanup
  • Loading branch information
mtmacdonald committed Dec 14, 2023
2 parents 4d44d14 + 0cf7807 commit d59c6bf
Show file tree
Hide file tree
Showing 19 changed files with 328 additions and 174 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docgen-tool",
"version": "3.5.0",
"version": "3.6.0",
"description": "A tool for creating HTML and PDF documentation",
"main": "dist/docgen.ts",
"bin": {
Expand Down
3 changes: 0 additions & 3 deletions src/docgen/fs/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ export const loadTemplates = async ({
redirect: await readFile(
__dirname + '/../../include/templates/redirect.html',
),
webCover: await readFile(
__dirname + '/../../include/templates/webCover.html',
),
pdfCover: await readFile(
__dirname + '/../../include/templates/pdfCover.html',
),
Expand Down
1 change: 0 additions & 1 deletion src/docgen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export type Meta = {
export type Templates = {
main?: string|TCheerioAPI,
redirect?: string|TCheerioAPI,
webCover?: string|TCheerioAPI,
pdfCover?: string|TCheerioAPI,
pdfHeader?: string|TCheerioAPI,
pdfFooter?: string|TCheerioAPI,
Expand Down
13 changes: 13 additions & 0 deletions src/docgen/views/components/logo/logo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";

export const Logo = ({
parameters,
}) => {
return (
parameters?.logoPath && (
<img
src={`../${parameters?.logoPath}`}
/>
)
)
};
2 changes: 1 addition & 1 deletion src/docgen/views/components/pdf-footer/pdf-footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const PdfFooter = ({
parameters
}) => {
return (
<div id="dg-footer">
<div id="dg-pdf-footer">
<table>
<thead></thead>
<tfoot></tfoot>
Expand Down
12 changes: 12 additions & 0 deletions src/docgen/views/components/pdf-header/pdf-header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { Logo } from "../logo/logo";

export const PdfHeader = ({
parameters
}) => {
return (
<div id="dg-pdf-header">
<Logo parameters={parameters} />
</div>
);
};
15 changes: 2 additions & 13 deletions src/docgen/views/pages/cover/pdf-cover.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import React from 'react';
import { Cover } from './cover';
import { Logo } from '../../components/logo/logo';
import { Footer } from '../../components/footer/footer';

const Logo = ({
parameters,
}) => {
return (
parameters?.logoPath && (
<img
src={`../${parameters?.logoPath}`}
/>
)
)
};

export const PdfCover = ({
parameters,
}) => {
Expand All @@ -25,7 +14,7 @@ export const PdfCover = ({
</div>
</div>
<Cover parameters={parameters} />
<div id="dg-footer">
<div id="dg-pdf-cover-footer">
<Footer parameters={parameters} />
</div>
</>
Expand Down
17 changes: 9 additions & 8 deletions src/docgen/views/pages/process-pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Main } from './main/main';
import { Cover } from './cover/cover';
import { toHTML } from "../html";
import { PdfCover } from "./cover/pdf-cover";
import { PdfHeader } from "../components/pdf-header/pdf-header";
import { PdfFooter } from "../components/pdf-footer/pdf-footer";

export const processTemplates = ({
Expand Down Expand Up @@ -71,8 +72,8 @@ export const processPages = async ({
const tableOfContents = contents;
const mainTemplate = hydratedTemplates.main;
const pdfCoverTemplate = hydratedTemplates.pdfCover;
const pdfHeaderTemplate = hydratedTemplates.pdfHeader;
const pdfFooterTemplate = hydratedTemplates.pdfFooter;
const webCover = hydratedTemplates.webCover;
const pdfEnabled = options.pdf;
console.log(pico.green('Generating the static web content'));
tableOfContents.forEach((section) => {
Expand Down Expand Up @@ -139,32 +140,32 @@ export const processPages = async ({
</Main>
);
let $ = cheerio.load(mainTemplate.html());
let webCoverStyles = cheerio.load(webCover.html());
$('head').append(webCoverStyles('head').html());
$('body').html(webCoverHtml);

const pdfCoverHtml = toHTML(
<PdfCover parameters={parameters} />
);
let $Pdf = cheerio.load(pdfCoverTemplate.html());
let pdfCoverStyles = cheerio.load(pdfCoverTemplate.html());
$Pdf('head').append(pdfCoverStyles('head').html());
$Pdf('body').html(pdfCoverHtml);

const pdfHeaderHtml = toHTML(
<PdfHeader parameters={parameters} />
);
let $PdfHeader = cheerio.load(pdfHeaderTemplate.html());
$PdfHeader('body').html(pdfHeaderHtml);

const pdfFooterHtml = toHTML(
<PdfFooter parameters={parameters} />
);
let $PdfFooter = cheerio.load(pdfFooterTemplate.html());
let pdfFooterStyles = cheerio.load(pdfFooterTemplate.html());
$PdfFooter('head').append(pdfFooterStyles('head').html());
$PdfFooter('body').html(pdfFooterHtml);

return {
pages,
redirect: hydratedTemplates.redirect,
webCover: $.html(),
pdfCover: $Pdf.html(),
pdfHeader: hydratedTemplates.pdfHeader.html(),
pdfHeader: $PdfHeader.html(),
pdfFooter: $PdfFooter.html(),
};
};
4 changes: 2 additions & 2 deletions src/docs/parameters.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"title": "DocGen - a documentation tool",
"name": "DocGen",
"version": "3.5.0",
"date": "04/12/2023",
"version": "3.6.0",
"date": "14/12/2023",
"organization": {
"name": "Inkit Inc. and contributors",
"url": "https://www.inkit.com"
Expand Down
6 changes: 5 additions & 1 deletion src/docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## DocGen 3.5.0 04/12/2023
## DocGen 3.6.0 14/12/2023

- simplify and improve styles layer

## DocGen 3.5.0 04/12/2023

- modernise view code (use React templates)

Expand Down
214 changes: 214 additions & 0 deletions src/include/require/styles/framework.css
Original file line number Diff line number Diff line change
Expand Up @@ -1040,3 +1040,217 @@ button .icon svg,
td.center {
display: table-cell;
}

#dg-coverInfo {
margin-top: 100px;
margin-bottom: 50px;
width: 100%;
}

#dg-coverInfo {
border-collapse: separate; /*http://stackoverflow.com/questions/7625586/*/
}

#dg-coverInfo th {
background-color: rgb(46, 113, 225);
color: white;
font-size: 34px;
padding: 20px;
border: 1px solid rgb(46, 113, 225);
border-radius: 10px 10px 0 0;
}

#dg-coverInfo tr td {
border-top: 2px solid rgb(46, 113, 225);
border-left: 2px solid rgb(46, 113, 225);
border-bottom: none;
border-right: none;
padding-top: 20px;
padding-bottom: 20px;
}

#dg-coverInfo td:last-child {
border-right: 2px solid rgb(46, 113, 225);
}

#dg-coverInfo .dg-finalRow td {
border-bottom: 2px solid rgb(46, 113, 225);
}

#dg-summary {
margin-bottom: 100px;
}

/*
PDF header
*/
#dg-pdf-header {
text-align: right;
}

/*
PDF cover
*/
#dg-pdfLogo {
display: inline-block;
float: right;
}

#dg-pdf-cover-footer {
width: 100%;
text-align: center;
}

/*
PDF footer
*/
#dg-pdf-footer {
border-top: 1px solid #385691;
padding-top: 10px;
}

#dg-pdf-footer table {
width: 100%;
text-align: center;
table-layout: fixed;
word-wrap: break-word;
}

#dg-pdf-footer a {
text-decoration: none;
color: #444;
}

pre {
font-size: 12px; /*todo - move to base styles*/
}

section blockquote p,
section li p {
margin: 0;
}

.w-table {
width: 100%;
}

/******************************** TABLE OF CONTENTS ****************************/
/*Table of contents button to initiate show/hide*/
#dg-navigator {
float: right;
background-color: rgb(26, 34, 49);
color: white;
text-align: right;
padding: 10px 20px 10px 20px;
margin-right: 200px;
border-radius: 0 0 10px 10px;
cursor: pointer;
font-weight: bold;
}

/*Table of contents container*/
#dg-toc {
color: white;
background-color: rgb(26, 34, 49);
}

#dg-toc table {
table-layout: auto;
width: 100%;
}

#dg-toc div {
padding: 15px 0 15px 0;
}

/*Columns in table of contents*/
#dg-toc td {
border-right: 1px solid #666;
vertical-align: top;
text-align: left;
padding: 0 20px 0 20px;
}

#dg-toc ul {
padding: 0;
list-style-type: none;
}

#dg-toc li {
font-weight: bold;
}

#dg-toc table td a {
color: white;
font-weight: normal;
text-decoration: none;
margin-left: 10px;
}

#dg-toc table td a:hover {
text-decoration: underline;
}

#dg-tocFixedColumn {
border-right: none;
}

#dg-toc table #dg-tocFixedColumn a {
vertical-align: middle;
margin-left: 4px;
}

.dg-tocGroup {
width: 22%;
}

.dg-tocHeading {
font-size: 16px;
}

.dg-tocIcon {
width: 18px;
height: 18px;
float: left;
}

.dg-tocIcon svg {
fill: white;
}

/*
Page table of contents
*/
.dg-pageToc {
list-style: none;
padding: 10px;
border: 1px solid #999;
background-color: #eee;
}

/*
Class to make a heading look invisible in web page, but still appear in the PDF table of contents
- display:none, visibily: hidden, zero dimensions, and offscreen positioning don't work
- so instead take it out of the flow and make it small and translucent
*/
.dg-hiddenTitle {
display: block;
border: none;
margin: 0;
padding: 0;
width: 1px;
height: 1px;
overflow: hidden;
position: absolute;
background-color: transparent;
}

.dg-fakeHeading {
text-decoration: none;
font-weight: bold;
color: #385691;
border-bottom: 1px solid #999;
margin: 20px 0 20px 0;
font-size: 16px;
padding-bottom: 4px;
}
Loading

0 comments on commit d59c6bf

Please sign in to comment.