Add support for light themes from bootswatch - #745

Merged
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes
Mar 23, 2019
Merged

Add support for light themes from bootswatch#745
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes

Conversation

@luyangkenneth

@luyangkennethluyangkenneth commented Mar 2, 2019

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X] New feature

Fixes#547, Fixes#663

High-level approach

The goal here is to enable themes in MarkBind! Building on the discussion in #547, the approach I'm going for is to:

  1. Incorporate bootswatch into the project via its npm package, instead of the other options. This is so that we can manage the dependency via npm, and be able to directly copy the css files without needing to download from a CDN.

  2. During the asset-copying stage of site generation, use the custom bootstrap.min.css of the specified bootswatch theme instead of the default bootstrap file.

  3. Allow users to change the theme of their site by specifying the name of the theme in site.json. At this point, this will be a global setting - no further granularity will be supported e.g. in the frontmatter or layout.

Non-goals

  • Adapt custom MarkBind components to use the overridden bootstrap css (to be done in a separate PR in the future)

Things I would like your input on (edit: these are resolved, thanks everyone!)

I wanted this to get reviewed at its early draft stage so that we have a consensus about what I'll be working on, and how best to go about it. I would appreciate your feedback! Here are some open questions I have:

  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

  2. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

  3. Do you have any concerns about the approach / next steps / anything that I've mentioned so far?

Example of what applying a diferent theme looks like

Screenshot 2019-03-14 at 5 07 42 PM

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Adding everyone as a reviewer to bring this to your attention. Feel free to involve yourself (or not) in the discussion 🙂

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

You can prevent that from happening by (temporarily) downgrading to npm 5.
I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Related: https://github.com/MarkBind/markbind-cli/wiki/Developer-Guide#troubleshooting (#582)

  1. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

If we want to claim theming support, then we should have light/dark versions of almost everything.
We don't want to (and cannot) support all Bootswatch themes nicely.

From your screenshot:

  • code blocks — look fine.
  • highlighting — not shown.
  • colour of the GitHub logo — cannot be changed: https://github.com/logos

@damithc

Copy link
Copy Markdown
Contributor

Shall we support only light themes at first? The need of the hour is for all MarkBind sites not to look exactly the same. That can be achieved with a range of light themes using different primary colors?

@Xenonym

Xenonym commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

@acjh@yamgent It's not so much a bug as it is a change in how package-lock.json is written in npm@6. The official advice is to:

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

colour of the GitHub logo — cannot be changed: github.com/logos

The download for the GitHub mark does have a light version for use on dark backgrounds, (and the GitHub navbar uses it) so a white on dark background logo should be OK.

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor

I didn't say it is a bug. It is an issue as the change is contentious.

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

I disagree. But @yamgent can decide for MarkBind.

@yamgent

Copy link
Copy Markdown
Member

I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Let's stick with npm 5 for now and not risk potentially breaking something.

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 13edb09 to 2beb325CompareMarch 14, 2019 08:33
@luyangkennethluyangkenneth changed the title [RFC] Add support for bootswatch themesAdd support for bootswatch themesMar 14, 2019
@luyangkennethluyangkenneth changed the title Add support for bootswatch themesAdd support for light themes from bootswatchMar 14, 2019
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 094300f to fa4ddf4CompareMarch 14, 2019 09:32
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Thanks for your inputs everyone! We have resolved the npm issue separately in #767, and I've updated this PR description accordingly.

As discussed, we'll only support light themes for now. I'm ready to have the code reviewed - please take a look 🙂 And then after everything is ok, I will proceed with writing the user docs.

@luyangkenneth
luyangkenneth marked this pull request as ready for review March 14, 2019 09:39
Comment threaddocs/site.json Outdated
}
],
"headingIndexingLevel": 6,
"bootswatchTheme": "journal",

@luyangkennethluyangkennethMar 14, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary change, to illustrate what modifying the theme looks like from the user's perspective.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"theme": "bootswatch-journal" is more future proof, in case we add support for other themes?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, yeah that sounds better 👍

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damithc - Updated! How does this look now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Comment threadsrc/Site.js Outdated
'spacelab',
'united',
'yeti',
];

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These correspond to subfolder names within bootswatch's node_modules folder.

Spelling of the themes are double checked with https://bootswatch.com/api/4.json

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from fa4ddf4 to 94d2bbbCompareMarch 14, 2019 10:12
Comment threadsrc/Site.js Outdated
return fs.copyAsync(this.siteAssetsSrcPath, this.siteAssetsDestPath);
const maybeOverrideDefaultBootstrapTheme = () => {
const { theme } = this.siteConfig;
if (!theme || !Object.prototype.hasOwnProperty.call(SUPPORTED_THEMES_PATHS, theme)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this check be simplified to _.has(SUPPORTED_THEMES_PATHS, theme)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, that definitely looks more readable. Done 👍

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 94d2bbb to 9475633CompareMarch 15, 2019 13:07
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Docs are up! 🎉

- [`bootswatch-spacelab`](https://bootswatch.com/spacelab/)
- [`bootswatch-united`](https://bootswatch.com/united/)
- [`bootswatch-yeti`](https://bootswatch.com/yeti/)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use images from bootswatch here (with proper acknowledgegements)? e.g.,

@luyangkennethluyangkennethMar 20, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that too. The images have straightforward URLs and should be easy to add to our docs. I think it might be reasonable to do that with proper acknowledgements, but I'm not fully sure about that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Themes are very visual things; it's best if we can provide a visual comparison. Also, we should avoid sending our users to external sites as much as possible.

Alternatively, we can duplicate the files in our site (but acknowledge the source). I think they use MIT license which allows duplication.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I'll go ahead with that then!

Comment threaddocs/userGuide/themes.md
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 28a84fc to bda3be3CompareMarch 20, 2019 11:50
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Screenshot 2019-03-20 at 7 43 44 PM

@damithc

Copy link
Copy Markdown
Contributor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Looks good, although the pics blends too well with the page due to white background in both. Perhaps put the whole lot inside a <box> so that the gray background can define the edge of each pic? Just a thought. I'm OK with the current one too.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Nice, yeah I agree it looks better:

Screenshot 2019-03-20 at 8 14 41 PM

@yamgentyamgent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍 Propose a merge commit message?

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@yamgent How about the PR title? :)

@yamgent

Copy link
Copy Markdown
Member

@yamgent How about the PR title? :)

The PR title alone is insufficient in providing the context of the change.

Proposed merge commit message:

Add built-in support for light themes from bootswatch (#745)
To use any custom Bootstrap themes, authors must manually copy over the
theme's .css files to the website's asset folders, and configure the
layout's head.md to use the .css files.
Let's add built-in support for bootswatch light themes, by providing a
"theme" option in site.json, so that authors can just directly specify
the name of the theme in order to use it. For example:
{ "theme": "bootswatch-cerulean"
}

@damithc

Copy link
Copy Markdown
Contributor

Commit message: you can also mention why only light themes are being added.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Whoops I thought you meant just the title of the merge commit. What you proposed sounds good to me!

Re: light themes, maybe we can append this to what you wrote:

Dark themes from Bootswatch are not yet supported because they require
our custom MarkBind components to inherit the Bootstrap styling classes,
to be done in #782.

@yamgentyamgent added this to the v1.21.1 milestone Mar 21, 2019

@Chng-Zhi-XuanChng-Zhi-Xuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Note that #782 should cover not just page-nav and site-nav but also other custom components that currently do not have any bootstrap classes.

E.G. Questions and Modals among many others. They do not allow customisation of how it looks currently (unlike panels or badges). So you have to implement customisation for them if we want everything within MarkBind to support theming.

@yamgent
yamgent merged commit c330dc9 into masterMar 23, 2019
@luyangkenneth
luyangkenneth deleted the support-bootswatch-themes branch March 23, 2019 06:21
@damithc

Copy link
Copy Markdown
Contributor

I'm testing out this feature now. Is it possible to get the navbar to change color too?
Like this:
image

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've investigated this briefly and I think this involves modifying our Navbar custom component to use the bg-primary class, in place of the bg-dark class it currently uses.

For example, if we apply the Journal theme (https://bootswatch.com/journal/), the generated website will have a black navbar (the second one in the list) as opposed to the pink navbar that we see in the thumbnail.


If we change the bootstrap class, the default navbar color will also change, based on the default bootstrap theme.

Using bg-dark (current)

Screenshot 2019-03-25 at 4 37 45 PM

Using bg-primary

Screenshot 2019-03-25 at 4 37 31 PM

But we can probably work around this by modifying how we specify our <navbar> in the user guide's header.md.

Would you like us to move in this direction? / What are your thoughts?

@damithc

Copy link
Copy Markdown
Contributor

Would you like us to move in this direction? / What are your thoughts?

It would be good to take advantage of the different nav bar colors as the navbar plays an important role in making the site look 'different'. It depends on how much effort it will take though. May be senior devs have some thoughts?

@acjh

acjh commented Mar 25, 2019

Copy link
Copy Markdown
Contributor

Let's continue this discussion in #386.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimal support for theming Support for bootswatch themes

6 participants

@luyangkenneth@acjh@damithc@Xenonym@yamgent@Chng-Zhi-Xuan
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Add support for light themes from bootswatch - #745

Merged
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes
Mar 23, 2019
Merged

Add support for light themes from bootswatch#745
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes

Conversation

@luyangkenneth

@luyangkennethluyangkenneth commented Mar 2, 2019

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X] New feature

Fixes#547, Fixes#663

High-level approach

The goal here is to enable themes in MarkBind! Building on the discussion in #547, the approach I'm going for is to:

  1. Incorporate bootswatch into the project via its npm package, instead of the other options. This is so that we can manage the dependency via npm, and be able to directly copy the css files without needing to download from a CDN.

  2. During the asset-copying stage of site generation, use the custom bootstrap.min.css of the specified bootswatch theme instead of the default bootstrap file.

  3. Allow users to change the theme of their site by specifying the name of the theme in site.json. At this point, this will be a global setting - no further granularity will be supported e.g. in the frontmatter or layout.

Non-goals

  • Adapt custom MarkBind components to use the overridden bootstrap css (to be done in a separate PR in the future)

Things I would like your input on (edit: these are resolved, thanks everyone!)

I wanted this to get reviewed at its early draft stage so that we have a consensus about what I'll be working on, and how best to go about it. I would appreciate your feedback! Here are some open questions I have:

  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

  2. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

  3. Do you have any concerns about the approach / next steps / anything that I've mentioned so far?

Example of what applying a diferent theme looks like

Screenshot 2019-03-14 at 5 07 42 PM

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Adding everyone as a reviewer to bring this to your attention. Feel free to involve yourself (or not) in the discussion 🙂

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

You can prevent that from happening by (temporarily) downgrading to npm 5.
I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Related: https://github.com/MarkBind/markbind-cli/wiki/Developer-Guide#troubleshooting (#582)

  1. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

If we want to claim theming support, then we should have light/dark versions of almost everything.
We don't want to (and cannot) support all Bootswatch themes nicely.

From your screenshot:

  • code blocks — look fine.
  • highlighting — not shown.
  • colour of the GitHub logo — cannot be changed: https://github.com/logos

@damithc

Copy link
Copy Markdown
Contributor

Shall we support only light themes at first? The need of the hour is for all MarkBind sites not to look exactly the same. That can be achieved with a range of light themes using different primary colors?

@Xenonym

Xenonym commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

@acjh@yamgent It's not so much a bug as it is a change in how package-lock.json is written in npm@6. The official advice is to:

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

colour of the GitHub logo — cannot be changed: github.com/logos

The download for the GitHub mark does have a light version for use on dark backgrounds, (and the GitHub navbar uses it) so a white on dark background logo should be OK.

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor

I didn't say it is a bug. It is an issue as the change is contentious.

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

I disagree. But @yamgent can decide for MarkBind.

@yamgent

Copy link
Copy Markdown
Member

I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Let's stick with npm 5 for now and not risk potentially breaking something.

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 13edb09 to 2beb325CompareMarch 14, 2019 08:33
@luyangkennethluyangkenneth changed the title [RFC] Add support for bootswatch themesAdd support for bootswatch themesMar 14, 2019
@luyangkennethluyangkenneth changed the title Add support for bootswatch themesAdd support for light themes from bootswatchMar 14, 2019
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 094300f to fa4ddf4CompareMarch 14, 2019 09:32
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Thanks for your inputs everyone! We have resolved the npm issue separately in #767, and I've updated this PR description accordingly.

As discussed, we'll only support light themes for now. I'm ready to have the code reviewed - please take a look 🙂 And then after everything is ok, I will proceed with writing the user docs.

@luyangkenneth
luyangkenneth marked this pull request as ready for review March 14, 2019 09:39
Comment threaddocs/site.json Outdated
}
],
"headingIndexingLevel": 6,
"bootswatchTheme": "journal",

@luyangkennethluyangkennethMar 14, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary change, to illustrate what modifying the theme looks like from the user's perspective.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"theme": "bootswatch-journal" is more future proof, in case we add support for other themes?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, yeah that sounds better 👍

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damithc - Updated! How does this look now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Comment threadsrc/Site.js Outdated
'spacelab',
'united',
'yeti',
];

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These correspond to subfolder names within bootswatch's node_modules folder.

Spelling of the themes are double checked with https://bootswatch.com/api/4.json

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from fa4ddf4 to 94d2bbbCompareMarch 14, 2019 10:12
Comment threadsrc/Site.js Outdated
return fs.copyAsync(this.siteAssetsSrcPath, this.siteAssetsDestPath);
const maybeOverrideDefaultBootstrapTheme = () => {
const { theme } = this.siteConfig;
if (!theme || !Object.prototype.hasOwnProperty.call(SUPPORTED_THEMES_PATHS, theme)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this check be simplified to _.has(SUPPORTED_THEMES_PATHS, theme)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, that definitely looks more readable. Done 👍

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 94d2bbb to 9475633CompareMarch 15, 2019 13:07
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Docs are up! 🎉

- [`bootswatch-spacelab`](https://bootswatch.com/spacelab/)
- [`bootswatch-united`](https://bootswatch.com/united/)
- [`bootswatch-yeti`](https://bootswatch.com/yeti/)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use images from bootswatch here (with proper acknowledgegements)? e.g.,

@luyangkennethluyangkennethMar 20, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that too. The images have straightforward URLs and should be easy to add to our docs. I think it might be reasonable to do that with proper acknowledgements, but I'm not fully sure about that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Themes are very visual things; it's best if we can provide a visual comparison. Also, we should avoid sending our users to external sites as much as possible.

Alternatively, we can duplicate the files in our site (but acknowledge the source). I think they use MIT license which allows duplication.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I'll go ahead with that then!

Comment threaddocs/userGuide/themes.md
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 28a84fc to bda3be3CompareMarch 20, 2019 11:50
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Screenshot 2019-03-20 at 7 43 44 PM

@damithc

Copy link
Copy Markdown
Contributor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Looks good, although the pics blends too well with the page due to white background in both. Perhaps put the whole lot inside a <box> so that the gray background can define the edge of each pic? Just a thought. I'm OK with the current one too.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Nice, yeah I agree it looks better:

Screenshot 2019-03-20 at 8 14 41 PM

@yamgentyamgent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍 Propose a merge commit message?

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@yamgent How about the PR title? :)

@yamgent

Copy link
Copy Markdown
Member

@yamgent How about the PR title? :)

The PR title alone is insufficient in providing the context of the change.

Proposed merge commit message:

Add built-in support for light themes from bootswatch (#745)
To use any custom Bootstrap themes, authors must manually copy over the
theme's .css files to the website's asset folders, and configure the
layout's head.md to use the .css files.
Let's add built-in support for bootswatch light themes, by providing a
"theme" option in site.json, so that authors can just directly specify
the name of the theme in order to use it. For example:
{ "theme": "bootswatch-cerulean"
}

@damithc

Copy link
Copy Markdown
Contributor

Commit message: you can also mention why only light themes are being added.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Whoops I thought you meant just the title of the merge commit. What you proposed sounds good to me!

Re: light themes, maybe we can append this to what you wrote:

Dark themes from Bootswatch are not yet supported because they require
our custom MarkBind components to inherit the Bootstrap styling classes,
to be done in #782.

@yamgentyamgent added this to the v1.21.1 milestone Mar 21, 2019

@Chng-Zhi-XuanChng-Zhi-Xuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Note that #782 should cover not just page-nav and site-nav but also other custom components that currently do not have any bootstrap classes.

E.G. Questions and Modals among many others. They do not allow customisation of how it looks currently (unlike panels or badges). So you have to implement customisation for them if we want everything within MarkBind to support theming.

@yamgent
yamgent merged commit c330dc9 into masterMar 23, 2019
@luyangkenneth
luyangkenneth deleted the support-bootswatch-themes branch March 23, 2019 06:21
@damithc

Copy link
Copy Markdown
Contributor

I'm testing out this feature now. Is it possible to get the navbar to change color too?
Like this:
image

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've investigated this briefly and I think this involves modifying our Navbar custom component to use the bg-primary class, in place of the bg-dark class it currently uses.

For example, if we apply the Journal theme (https://bootswatch.com/journal/), the generated website will have a black navbar (the second one in the list) as opposed to the pink navbar that we see in the thumbnail.


If we change the bootstrap class, the default navbar color will also change, based on the default bootstrap theme.

Using bg-dark (current)

Screenshot 2019-03-25 at 4 37 45 PM

Using bg-primary

Screenshot 2019-03-25 at 4 37 31 PM

But we can probably work around this by modifying how we specify our <navbar> in the user guide's header.md.

Would you like us to move in this direction? / What are your thoughts?

@damithc

Copy link
Copy Markdown
Contributor

Would you like us to move in this direction? / What are your thoughts?

It would be good to take advantage of the different nav bar colors as the navbar plays an important role in making the site look 'different'. It depends on how much effort it will take though. May be senior devs have some thoughts?

@acjh

acjh commented Mar 25, 2019

Copy link
Copy Markdown
Contributor

Let's continue this discussion in #386.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimal support for theming Support for bootswatch themes

6 participants

@luyangkenneth@acjh@damithc@Xenonym@yamgent@Chng-Zhi-Xuan
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add support for light themes from bootswatch - #745

Merged
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes
Mar 23, 2019
Merged

Add support for light themes from bootswatch#745
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes

Conversation

@luyangkenneth

@luyangkennethluyangkenneth commented Mar 2, 2019

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X] New feature

Fixes#547, Fixes#663

High-level approach

The goal here is to enable themes in MarkBind! Building on the discussion in #547, the approach I'm going for is to:

  1. Incorporate bootswatch into the project via its npm package, instead of the other options. This is so that we can manage the dependency via npm, and be able to directly copy the css files without needing to download from a CDN.

  2. During the asset-copying stage of site generation, use the custom bootstrap.min.css of the specified bootswatch theme instead of the default bootstrap file.

  3. Allow users to change the theme of their site by specifying the name of the theme in site.json. At this point, this will be a global setting - no further granularity will be supported e.g. in the frontmatter or layout.

Non-goals

  • Adapt custom MarkBind components to use the overridden bootstrap css (to be done in a separate PR in the future)

Things I would like your input on (edit: these are resolved, thanks everyone!)

I wanted this to get reviewed at its early draft stage so that we have a consensus about what I'll be working on, and how best to go about it. I would appreciate your feedback! Here are some open questions I have:

  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

  2. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

  3. Do you have any concerns about the approach / next steps / anything that I've mentioned so far?

Example of what applying a diferent theme looks like

Screenshot 2019-03-14 at 5 07 42 PM

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Adding everyone as a reviewer to bring this to your attention. Feel free to involve yourself (or not) in the discussion 🙂

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

You can prevent that from happening by (temporarily) downgrading to npm 5.
I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Related: https://github.com/MarkBind/markbind-cli/wiki/Developer-Guide#troubleshooting (#582)

  1. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

If we want to claim theming support, then we should have light/dark versions of almost everything.
We don't want to (and cannot) support all Bootswatch themes nicely.

From your screenshot:

  • code blocks — look fine.
  • highlighting — not shown.
  • colour of the GitHub logo — cannot be changed: https://github.com/logos

@damithc

Copy link
Copy Markdown
Contributor

Shall we support only light themes at first? The need of the hour is for all MarkBind sites not to look exactly the same. That can be achieved with a range of light themes using different primary colors?

@Xenonym

Xenonym commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

@acjh@yamgent It's not so much a bug as it is a change in how package-lock.json is written in npm@6. The official advice is to:

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

colour of the GitHub logo — cannot be changed: github.com/logos

The download for the GitHub mark does have a light version for use on dark backgrounds, (and the GitHub navbar uses it) so a white on dark background logo should be OK.

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor

I didn't say it is a bug. It is an issue as the change is contentious.

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

I disagree. But @yamgent can decide for MarkBind.

@yamgent

Copy link
Copy Markdown
Member

I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Let's stick with npm 5 for now and not risk potentially breaking something.

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 13edb09 to 2beb325CompareMarch 14, 2019 08:33
@luyangkennethluyangkenneth changed the title [RFC] Add support for bootswatch themesAdd support for bootswatch themesMar 14, 2019
@luyangkennethluyangkenneth changed the title Add support for bootswatch themesAdd support for light themes from bootswatchMar 14, 2019
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 094300f to fa4ddf4CompareMarch 14, 2019 09:32
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Thanks for your inputs everyone! We have resolved the npm issue separately in #767, and I've updated this PR description accordingly.

As discussed, we'll only support light themes for now. I'm ready to have the code reviewed - please take a look 🙂 And then after everything is ok, I will proceed with writing the user docs.

@luyangkenneth
luyangkenneth marked this pull request as ready for review March 14, 2019 09:39
Comment threaddocs/site.json Outdated
}
],
"headingIndexingLevel": 6,
"bootswatchTheme": "journal",

@luyangkennethluyangkennethMar 14, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary change, to illustrate what modifying the theme looks like from the user's perspective.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"theme": "bootswatch-journal" is more future proof, in case we add support for other themes?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, yeah that sounds better 👍

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damithc - Updated! How does this look now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Comment threadsrc/Site.js Outdated
'spacelab',
'united',
'yeti',
];

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These correspond to subfolder names within bootswatch's node_modules folder.

Spelling of the themes are double checked with https://bootswatch.com/api/4.json

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from fa4ddf4 to 94d2bbbCompareMarch 14, 2019 10:12
Comment threadsrc/Site.js Outdated
return fs.copyAsync(this.siteAssetsSrcPath, this.siteAssetsDestPath);
const maybeOverrideDefaultBootstrapTheme = () => {
const { theme } = this.siteConfig;
if (!theme || !Object.prototype.hasOwnProperty.call(SUPPORTED_THEMES_PATHS, theme)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this check be simplified to _.has(SUPPORTED_THEMES_PATHS, theme)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, that definitely looks more readable. Done 👍

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 94d2bbb to 9475633CompareMarch 15, 2019 13:07
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Docs are up! 🎉

- [`bootswatch-spacelab`](https://bootswatch.com/spacelab/)
- [`bootswatch-united`](https://bootswatch.com/united/)
- [`bootswatch-yeti`](https://bootswatch.com/yeti/)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use images from bootswatch here (with proper acknowledgegements)? e.g.,

@luyangkennethluyangkennethMar 20, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that too. The images have straightforward URLs and should be easy to add to our docs. I think it might be reasonable to do that with proper acknowledgements, but I'm not fully sure about that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Themes are very visual things; it's best if we can provide a visual comparison. Also, we should avoid sending our users to external sites as much as possible.

Alternatively, we can duplicate the files in our site (but acknowledge the source). I think they use MIT license which allows duplication.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I'll go ahead with that then!

Comment threaddocs/userGuide/themes.md
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 28a84fc to bda3be3CompareMarch 20, 2019 11:50
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Screenshot 2019-03-20 at 7 43 44 PM

@damithc

Copy link
Copy Markdown
Contributor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Looks good, although the pics blends too well with the page due to white background in both. Perhaps put the whole lot inside a <box> so that the gray background can define the edge of each pic? Just a thought. I'm OK with the current one too.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Nice, yeah I agree it looks better:

Screenshot 2019-03-20 at 8 14 41 PM

@yamgentyamgent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍 Propose a merge commit message?

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@yamgent How about the PR title? :)

@yamgent

Copy link
Copy Markdown
Member

@yamgent How about the PR title? :)

The PR title alone is insufficient in providing the context of the change.

Proposed merge commit message:

Add built-in support for light themes from bootswatch (#745)
To use any custom Bootstrap themes, authors must manually copy over the
theme's .css files to the website's asset folders, and configure the
layout's head.md to use the .css files.
Let's add built-in support for bootswatch light themes, by providing a
"theme" option in site.json, so that authors can just directly specify
the name of the theme in order to use it. For example:
{ "theme": "bootswatch-cerulean"
}

@damithc

Copy link
Copy Markdown
Contributor

Commit message: you can also mention why only light themes are being added.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Whoops I thought you meant just the title of the merge commit. What you proposed sounds good to me!

Re: light themes, maybe we can append this to what you wrote:

Dark themes from Bootswatch are not yet supported because they require
our custom MarkBind components to inherit the Bootstrap styling classes,
to be done in #782.

@yamgentyamgent added this to the v1.21.1 milestone Mar 21, 2019

@Chng-Zhi-XuanChng-Zhi-Xuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Note that #782 should cover not just page-nav and site-nav but also other custom components that currently do not have any bootstrap classes.

E.G. Questions and Modals among many others. They do not allow customisation of how it looks currently (unlike panels or badges). So you have to implement customisation for them if we want everything within MarkBind to support theming.

@yamgent
yamgent merged commit c330dc9 into masterMar 23, 2019
@luyangkenneth
luyangkenneth deleted the support-bootswatch-themes branch March 23, 2019 06:21
@damithc

Copy link
Copy Markdown
Contributor

I'm testing out this feature now. Is it possible to get the navbar to change color too?
Like this:
image

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've investigated this briefly and I think this involves modifying our Navbar custom component to use the bg-primary class, in place of the bg-dark class it currently uses.

For example, if we apply the Journal theme (https://bootswatch.com/journal/), the generated website will have a black navbar (the second one in the list) as opposed to the pink navbar that we see in the thumbnail.


If we change the bootstrap class, the default navbar color will also change, based on the default bootstrap theme.

Using bg-dark (current)

Screenshot 2019-03-25 at 4 37 45 PM

Using bg-primary

Screenshot 2019-03-25 at 4 37 31 PM

But we can probably work around this by modifying how we specify our <navbar> in the user guide's header.md.

Would you like us to move in this direction? / What are your thoughts?

@damithc

Copy link
Copy Markdown
Contributor

Would you like us to move in this direction? / What are your thoughts?

It would be good to take advantage of the different nav bar colors as the navbar plays an important role in making the site look 'different'. It depends on how much effort it will take though. May be senior devs have some thoughts?

@acjh

acjh commented Mar 25, 2019

Copy link
Copy Markdown
Contributor

Let's continue this discussion in #386.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimal support for theming Support for bootswatch themes

6 participants

@luyangkenneth@acjh@damithc@Xenonym@yamgent@Chng-Zhi-Xuan
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add support for light themes from bootswatch - #745

Merged
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes
Mar 23, 2019
Merged

Add support for light themes from bootswatch#745
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes

Conversation

@luyangkenneth

@luyangkennethluyangkenneth commented Mar 2, 2019

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X] New feature

Fixes#547, Fixes#663

High-level approach

The goal here is to enable themes in MarkBind! Building on the discussion in #547, the approach I'm going for is to:

  1. Incorporate bootswatch into the project via its npm package, instead of the other options. This is so that we can manage the dependency via npm, and be able to directly copy the css files without needing to download from a CDN.

  2. During the asset-copying stage of site generation, use the custom bootstrap.min.css of the specified bootswatch theme instead of the default bootstrap file.

  3. Allow users to change the theme of their site by specifying the name of the theme in site.json. At this point, this will be a global setting - no further granularity will be supported e.g. in the frontmatter or layout.

Non-goals

  • Adapt custom MarkBind components to use the overridden bootstrap css (to be done in a separate PR in the future)

Things I would like your input on (edit: these are resolved, thanks everyone!)

I wanted this to get reviewed at its early draft stage so that we have a consensus about what I'll be working on, and how best to go about it. I would appreciate your feedback! Here are some open questions I have:

  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

  2. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

  3. Do you have any concerns about the approach / next steps / anything that I've mentioned so far?

Example of what applying a diferent theme looks like

Screenshot 2019-03-14 at 5 07 42 PM

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Adding everyone as a reviewer to bring this to your attention. Feel free to involve yourself (or not) in the discussion 🙂

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

You can prevent that from happening by (temporarily) downgrading to npm 5.
I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Related: https://github.com/MarkBind/markbind-cli/wiki/Developer-Guide#troubleshooting (#582)

  1. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

If we want to claim theming support, then we should have light/dark versions of almost everything.
We don't want to (and cannot) support all Bootswatch themes nicely.

From your screenshot:

  • code blocks — look fine.
  • highlighting — not shown.
  • colour of the GitHub logo — cannot be changed: https://github.com/logos

@damithc

Copy link
Copy Markdown
Contributor

Shall we support only light themes at first? The need of the hour is for all MarkBind sites not to look exactly the same. That can be achieved with a range of light themes using different primary colors?

@Xenonym

Xenonym commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

@acjh@yamgent It's not so much a bug as it is a change in how package-lock.json is written in npm@6. The official advice is to:

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

colour of the GitHub logo — cannot be changed: github.com/logos

The download for the GitHub mark does have a light version for use on dark backgrounds, (and the GitHub navbar uses it) so a white on dark background logo should be OK.

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor

I didn't say it is a bug. It is an issue as the change is contentious.

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

I disagree. But @yamgent can decide for MarkBind.

@yamgent

Copy link
Copy Markdown
Member

I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Let's stick with npm 5 for now and not risk potentially breaking something.

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 13edb09 to 2beb325CompareMarch 14, 2019 08:33
@luyangkennethluyangkenneth changed the title [RFC] Add support for bootswatch themesAdd support for bootswatch themesMar 14, 2019
@luyangkennethluyangkenneth changed the title Add support for bootswatch themesAdd support for light themes from bootswatchMar 14, 2019
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 094300f to fa4ddf4CompareMarch 14, 2019 09:32
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Thanks for your inputs everyone! We have resolved the npm issue separately in #767, and I've updated this PR description accordingly.

As discussed, we'll only support light themes for now. I'm ready to have the code reviewed - please take a look 🙂 And then after everything is ok, I will proceed with writing the user docs.

@luyangkenneth
luyangkenneth marked this pull request as ready for review March 14, 2019 09:39
Comment threaddocs/site.json Outdated
}
],
"headingIndexingLevel": 6,
"bootswatchTheme": "journal",

@luyangkennethluyangkennethMar 14, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary change, to illustrate what modifying the theme looks like from the user's perspective.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"theme": "bootswatch-journal" is more future proof, in case we add support for other themes?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, yeah that sounds better 👍

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damithc - Updated! How does this look now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Comment threadsrc/Site.js Outdated
'spacelab',
'united',
'yeti',
];

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These correspond to subfolder names within bootswatch's node_modules folder.

Spelling of the themes are double checked with https://bootswatch.com/api/4.json

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from fa4ddf4 to 94d2bbbCompareMarch 14, 2019 10:12
Comment threadsrc/Site.js Outdated
return fs.copyAsync(this.siteAssetsSrcPath, this.siteAssetsDestPath);
const maybeOverrideDefaultBootstrapTheme = () => {
const { theme } = this.siteConfig;
if (!theme || !Object.prototype.hasOwnProperty.call(SUPPORTED_THEMES_PATHS, theme)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this check be simplified to _.has(SUPPORTED_THEMES_PATHS, theme)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, that definitely looks more readable. Done 👍

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 94d2bbb to 9475633CompareMarch 15, 2019 13:07
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Docs are up! 🎉

- [`bootswatch-spacelab`](https://bootswatch.com/spacelab/)
- [`bootswatch-united`](https://bootswatch.com/united/)
- [`bootswatch-yeti`](https://bootswatch.com/yeti/)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use images from bootswatch here (with proper acknowledgegements)? e.g.,

@luyangkennethluyangkennethMar 20, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that too. The images have straightforward URLs and should be easy to add to our docs. I think it might be reasonable to do that with proper acknowledgements, but I'm not fully sure about that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Themes are very visual things; it's best if we can provide a visual comparison. Also, we should avoid sending our users to external sites as much as possible.

Alternatively, we can duplicate the files in our site (but acknowledge the source). I think they use MIT license which allows duplication.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I'll go ahead with that then!

Comment threaddocs/userGuide/themes.md
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 28a84fc to bda3be3CompareMarch 20, 2019 11:50
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Screenshot 2019-03-20 at 7 43 44 PM

@damithc

Copy link
Copy Markdown
Contributor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Looks good, although the pics blends too well with the page due to white background in both. Perhaps put the whole lot inside a <box> so that the gray background can define the edge of each pic? Just a thought. I'm OK with the current one too.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Nice, yeah I agree it looks better:

Screenshot 2019-03-20 at 8 14 41 PM

@yamgentyamgent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍 Propose a merge commit message?

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@yamgent How about the PR title? :)

@yamgent

Copy link
Copy Markdown
Member

@yamgent How about the PR title? :)

The PR title alone is insufficient in providing the context of the change.

Proposed merge commit message:

Add built-in support for light themes from bootswatch (#745)
To use any custom Bootstrap themes, authors must manually copy over the
theme's .css files to the website's asset folders, and configure the
layout's head.md to use the .css files.
Let's add built-in support for bootswatch light themes, by providing a
"theme" option in site.json, so that authors can just directly specify
the name of the theme in order to use it. For example:
{ "theme": "bootswatch-cerulean"
}

@damithc

Copy link
Copy Markdown
Contributor

Commit message: you can also mention why only light themes are being added.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Whoops I thought you meant just the title of the merge commit. What you proposed sounds good to me!

Re: light themes, maybe we can append this to what you wrote:

Dark themes from Bootswatch are not yet supported because they require
our custom MarkBind components to inherit the Bootstrap styling classes,
to be done in #782.

@yamgentyamgent added this to the v1.21.1 milestone Mar 21, 2019

@Chng-Zhi-XuanChng-Zhi-Xuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Note that #782 should cover not just page-nav and site-nav but also other custom components that currently do not have any bootstrap classes.

E.G. Questions and Modals among many others. They do not allow customisation of how it looks currently (unlike panels or badges). So you have to implement customisation for them if we want everything within MarkBind to support theming.

@yamgent
yamgent merged commit c330dc9 into masterMar 23, 2019
@luyangkenneth
luyangkenneth deleted the support-bootswatch-themes branch March 23, 2019 06:21
@damithc

Copy link
Copy Markdown
Contributor

I'm testing out this feature now. Is it possible to get the navbar to change color too?
Like this:
image

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've investigated this briefly and I think this involves modifying our Navbar custom component to use the bg-primary class, in place of the bg-dark class it currently uses.

For example, if we apply the Journal theme (https://bootswatch.com/journal/), the generated website will have a black navbar (the second one in the list) as opposed to the pink navbar that we see in the thumbnail.


If we change the bootstrap class, the default navbar color will also change, based on the default bootstrap theme.

Using bg-dark (current)

Screenshot 2019-03-25 at 4 37 45 PM

Using bg-primary

Screenshot 2019-03-25 at 4 37 31 PM

But we can probably work around this by modifying how we specify our <navbar> in the user guide's header.md.

Would you like us to move in this direction? / What are your thoughts?

@damithc

Copy link
Copy Markdown
Contributor

Would you like us to move in this direction? / What are your thoughts?

It would be good to take advantage of the different nav bar colors as the navbar plays an important role in making the site look 'different'. It depends on how much effort it will take though. May be senior devs have some thoughts?

@acjh

acjh commented Mar 25, 2019

Copy link
Copy Markdown
Contributor

Let's continue this discussion in #386.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimal support for theming Support for bootswatch themes

6 participants

@luyangkenneth@acjh@damithc@Xenonym@yamgent@Chng-Zhi-Xuan
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Add support for light themes from bootswatch - #745

Merged
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes
Mar 23, 2019
Merged

Add support for light themes from bootswatch#745
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes

Conversation

@luyangkenneth

@luyangkennethluyangkenneth commented Mar 2, 2019

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X] New feature

Fixes#547, Fixes#663

High-level approach

The goal here is to enable themes in MarkBind! Building on the discussion in #547, the approach I'm going for is to:

  1. Incorporate bootswatch into the project via its npm package, instead of the other options. This is so that we can manage the dependency via npm, and be able to directly copy the css files without needing to download from a CDN.

  2. During the asset-copying stage of site generation, use the custom bootstrap.min.css of the specified bootswatch theme instead of the default bootstrap file.

  3. Allow users to change the theme of their site by specifying the name of the theme in site.json. At this point, this will be a global setting - no further granularity will be supported e.g. in the frontmatter or layout.

Non-goals

  • Adapt custom MarkBind components to use the overridden bootstrap css (to be done in a separate PR in the future)

Things I would like your input on (edit: these are resolved, thanks everyone!)

I wanted this to get reviewed at its early draft stage so that we have a consensus about what I'll be working on, and how best to go about it. I would appreciate your feedback! Here are some open questions I have:

  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

  2. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

  3. Do you have any concerns about the approach / next steps / anything that I've mentioned so far?

Example of what applying a diferent theme looks like

Screenshot 2019-03-14 at 5 07 42 PM

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Adding everyone as a reviewer to bring this to your attention. Feel free to involve yourself (or not) in the discussion 🙂

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

You can prevent that from happening by (temporarily) downgrading to npm 5.
I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Related: https://github.com/MarkBind/markbind-cli/wiki/Developer-Guide#troubleshooting (#582)

  1. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

If we want to claim theming support, then we should have light/dark versions of almost everything.
We don't want to (and cannot) support all Bootswatch themes nicely.

From your screenshot:

  • code blocks — look fine.
  • highlighting — not shown.
  • colour of the GitHub logo — cannot be changed: https://github.com/logos

@damithc

Copy link
Copy Markdown
Contributor

Shall we support only light themes at first? The need of the hour is for all MarkBind sites not to look exactly the same. That can be achieved with a range of light themes using different primary colors?

@Xenonym

Xenonym commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

@acjh@yamgent It's not so much a bug as it is a change in how package-lock.json is written in npm@6. The official advice is to:

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

colour of the GitHub logo — cannot be changed: github.com/logos

The download for the GitHub mark does have a light version for use on dark backgrounds, (and the GitHub navbar uses it) so a white on dark background logo should be OK.

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor

I didn't say it is a bug. It is an issue as the change is contentious.

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

I disagree. But @yamgent can decide for MarkBind.

@yamgent

Copy link
Copy Markdown
Member

I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Let's stick with npm 5 for now and not risk potentially breaking something.

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 13edb09 to 2beb325CompareMarch 14, 2019 08:33
@luyangkennethluyangkenneth changed the title [RFC] Add support for bootswatch themesAdd support for bootswatch themesMar 14, 2019
@luyangkennethluyangkenneth changed the title Add support for bootswatch themesAdd support for light themes from bootswatchMar 14, 2019
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 094300f to fa4ddf4CompareMarch 14, 2019 09:32
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Thanks for your inputs everyone! We have resolved the npm issue separately in #767, and I've updated this PR description accordingly.

As discussed, we'll only support light themes for now. I'm ready to have the code reviewed - please take a look 🙂 And then after everything is ok, I will proceed with writing the user docs.

@luyangkenneth
luyangkenneth marked this pull request as ready for review March 14, 2019 09:39
Comment threaddocs/site.json Outdated
}
],
"headingIndexingLevel": 6,
"bootswatchTheme": "journal",

@luyangkennethluyangkennethMar 14, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary change, to illustrate what modifying the theme looks like from the user's perspective.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"theme": "bootswatch-journal" is more future proof, in case we add support for other themes?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, yeah that sounds better 👍

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damithc - Updated! How does this look now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Comment threadsrc/Site.js Outdated
'spacelab',
'united',
'yeti',
];

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These correspond to subfolder names within bootswatch's node_modules folder.

Spelling of the themes are double checked with https://bootswatch.com/api/4.json

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from fa4ddf4 to 94d2bbbCompareMarch 14, 2019 10:12
Comment threadsrc/Site.js Outdated
return fs.copyAsync(this.siteAssetsSrcPath, this.siteAssetsDestPath);
const maybeOverrideDefaultBootstrapTheme = () => {
const { theme } = this.siteConfig;
if (!theme || !Object.prototype.hasOwnProperty.call(SUPPORTED_THEMES_PATHS, theme)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this check be simplified to _.has(SUPPORTED_THEMES_PATHS, theme)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, that definitely looks more readable. Done 👍

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 94d2bbb to 9475633CompareMarch 15, 2019 13:07
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Docs are up! 🎉

- [`bootswatch-spacelab`](https://bootswatch.com/spacelab/)
- [`bootswatch-united`](https://bootswatch.com/united/)
- [`bootswatch-yeti`](https://bootswatch.com/yeti/)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use images from bootswatch here (with proper acknowledgegements)? e.g.,

@luyangkennethluyangkennethMar 20, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that too. The images have straightforward URLs and should be easy to add to our docs. I think it might be reasonable to do that with proper acknowledgements, but I'm not fully sure about that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Themes are very visual things; it's best if we can provide a visual comparison. Also, we should avoid sending our users to external sites as much as possible.

Alternatively, we can duplicate the files in our site (but acknowledge the source). I think they use MIT license which allows duplication.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I'll go ahead with that then!

Comment threaddocs/userGuide/themes.md
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 28a84fc to bda3be3CompareMarch 20, 2019 11:50
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Screenshot 2019-03-20 at 7 43 44 PM

@damithc

Copy link
Copy Markdown
Contributor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Looks good, although the pics blends too well with the page due to white background in both. Perhaps put the whole lot inside a <box> so that the gray background can define the edge of each pic? Just a thought. I'm OK with the current one too.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Nice, yeah I agree it looks better:

Screenshot 2019-03-20 at 8 14 41 PM

@yamgentyamgent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍 Propose a merge commit message?

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@yamgent How about the PR title? :)

@yamgent

Copy link
Copy Markdown
Member

@yamgent How about the PR title? :)

The PR title alone is insufficient in providing the context of the change.

Proposed merge commit message:

Add built-in support for light themes from bootswatch (#745)
To use any custom Bootstrap themes, authors must manually copy over the
theme's .css files to the website's asset folders, and configure the
layout's head.md to use the .css files.
Let's add built-in support for bootswatch light themes, by providing a
"theme" option in site.json, so that authors can just directly specify
the name of the theme in order to use it. For example:
{ "theme": "bootswatch-cerulean"
}

@damithc

Copy link
Copy Markdown
Contributor

Commit message: you can also mention why only light themes are being added.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Whoops I thought you meant just the title of the merge commit. What you proposed sounds good to me!

Re: light themes, maybe we can append this to what you wrote:

Dark themes from Bootswatch are not yet supported because they require
our custom MarkBind components to inherit the Bootstrap styling classes,
to be done in #782.

@yamgentyamgent added this to the v1.21.1 milestone Mar 21, 2019

@Chng-Zhi-XuanChng-Zhi-Xuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Note that #782 should cover not just page-nav and site-nav but also other custom components that currently do not have any bootstrap classes.

E.G. Questions and Modals among many others. They do not allow customisation of how it looks currently (unlike panels or badges). So you have to implement customisation for them if we want everything within MarkBind to support theming.

@yamgent
yamgent merged commit c330dc9 into masterMar 23, 2019
@luyangkenneth
luyangkenneth deleted the support-bootswatch-themes branch March 23, 2019 06:21
@damithc

Copy link
Copy Markdown
Contributor

I'm testing out this feature now. Is it possible to get the navbar to change color too?
Like this:
image

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've investigated this briefly and I think this involves modifying our Navbar custom component to use the bg-primary class, in place of the bg-dark class it currently uses.

For example, if we apply the Journal theme (https://bootswatch.com/journal/), the generated website will have a black navbar (the second one in the list) as opposed to the pink navbar that we see in the thumbnail.


If we change the bootstrap class, the default navbar color will also change, based on the default bootstrap theme.

Using bg-dark (current)

Screenshot 2019-03-25 at 4 37 45 PM

Using bg-primary

Screenshot 2019-03-25 at 4 37 31 PM

But we can probably work around this by modifying how we specify our <navbar> in the user guide's header.md.

Would you like us to move in this direction? / What are your thoughts?

@damithc

Copy link
Copy Markdown
Contributor

Would you like us to move in this direction? / What are your thoughts?

It would be good to take advantage of the different nav bar colors as the navbar plays an important role in making the site look 'different'. It depends on how much effort it will take though. May be senior devs have some thoughts?

@acjh

acjh commented Mar 25, 2019

Copy link
Copy Markdown
Contributor

Let's continue this discussion in #386.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimal support for theming Support for bootswatch themes

6 participants

@luyangkenneth@acjh@damithc@Xenonym@yamgent@Chng-Zhi-Xuan
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add support for light themes from bootswatch - #745

Merged
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes
Mar 23, 2019
Merged

Add support for light themes from bootswatch#745
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes

Conversation

@luyangkenneth

@luyangkennethluyangkenneth commented Mar 2, 2019

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X] New feature

Fixes#547, Fixes#663

High-level approach

The goal here is to enable themes in MarkBind! Building on the discussion in #547, the approach I'm going for is to:

  1. Incorporate bootswatch into the project via its npm package, instead of the other options. This is so that we can manage the dependency via npm, and be able to directly copy the css files without needing to download from a CDN.

  2. During the asset-copying stage of site generation, use the custom bootstrap.min.css of the specified bootswatch theme instead of the default bootstrap file.

  3. Allow users to change the theme of their site by specifying the name of the theme in site.json. At this point, this will be a global setting - no further granularity will be supported e.g. in the frontmatter or layout.

Non-goals

  • Adapt custom MarkBind components to use the overridden bootstrap css (to be done in a separate PR in the future)

Things I would like your input on (edit: these are resolved, thanks everyone!)

I wanted this to get reviewed at its early draft stage so that we have a consensus about what I'll be working on, and how best to go about it. I would appreciate your feedback! Here are some open questions I have:

  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

  2. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

  3. Do you have any concerns about the approach / next steps / anything that I've mentioned so far?

Example of what applying a diferent theme looks like

Screenshot 2019-03-14 at 5 07 42 PM

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Adding everyone as a reviewer to bring this to your attention. Feel free to involve yourself (or not) in the discussion 🙂

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

You can prevent that from happening by (temporarily) downgrading to npm 5.
I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Related: https://github.com/MarkBind/markbind-cli/wiki/Developer-Guide#troubleshooting (#582)

  1. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

If we want to claim theming support, then we should have light/dark versions of almost everything.
We don't want to (and cannot) support all Bootswatch themes nicely.

From your screenshot:

  • code blocks — look fine.
  • highlighting — not shown.
  • colour of the GitHub logo — cannot be changed: https://github.com/logos

@damithc

Copy link
Copy Markdown
Contributor

Shall we support only light themes at first? The need of the hour is for all MarkBind sites not to look exactly the same. That can be achieved with a range of light themes using different primary colors?

@Xenonym

Xenonym commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

@acjh@yamgent It's not so much a bug as it is a change in how package-lock.json is written in npm@6. The official advice is to:

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

colour of the GitHub logo — cannot be changed: github.com/logos

The download for the GitHub mark does have a light version for use on dark backgrounds, (and the GitHub navbar uses it) so a white on dark background logo should be OK.

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor

I didn't say it is a bug. It is an issue as the change is contentious.

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

I disagree. But @yamgent can decide for MarkBind.

@yamgent

Copy link
Copy Markdown
Member

I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Let's stick with npm 5 for now and not risk potentially breaking something.

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 13edb09 to 2beb325CompareMarch 14, 2019 08:33
@luyangkennethluyangkenneth changed the title [RFC] Add support for bootswatch themesAdd support for bootswatch themesMar 14, 2019
@luyangkennethluyangkenneth changed the title Add support for bootswatch themesAdd support for light themes from bootswatchMar 14, 2019
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 094300f to fa4ddf4CompareMarch 14, 2019 09:32
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Thanks for your inputs everyone! We have resolved the npm issue separately in #767, and I've updated this PR description accordingly.

As discussed, we'll only support light themes for now. I'm ready to have the code reviewed - please take a look 🙂 And then after everything is ok, I will proceed with writing the user docs.

@luyangkenneth
luyangkenneth marked this pull request as ready for review March 14, 2019 09:39
Comment threaddocs/site.json Outdated
}
],
"headingIndexingLevel": 6,
"bootswatchTheme": "journal",

@luyangkennethluyangkennethMar 14, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary change, to illustrate what modifying the theme looks like from the user's perspective.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"theme": "bootswatch-journal" is more future proof, in case we add support for other themes?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, yeah that sounds better 👍

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damithc - Updated! How does this look now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Comment threadsrc/Site.js Outdated
'spacelab',
'united',
'yeti',
];

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These correspond to subfolder names within bootswatch's node_modules folder.

Spelling of the themes are double checked with https://bootswatch.com/api/4.json

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from fa4ddf4 to 94d2bbbCompareMarch 14, 2019 10:12
Comment threadsrc/Site.js Outdated
return fs.copyAsync(this.siteAssetsSrcPath, this.siteAssetsDestPath);
const maybeOverrideDefaultBootstrapTheme = () => {
const { theme } = this.siteConfig;
if (!theme || !Object.prototype.hasOwnProperty.call(SUPPORTED_THEMES_PATHS, theme)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this check be simplified to _.has(SUPPORTED_THEMES_PATHS, theme)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, that definitely looks more readable. Done 👍

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 94d2bbb to 9475633CompareMarch 15, 2019 13:07
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Docs are up! 🎉

- [`bootswatch-spacelab`](https://bootswatch.com/spacelab/)
- [`bootswatch-united`](https://bootswatch.com/united/)
- [`bootswatch-yeti`](https://bootswatch.com/yeti/)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use images from bootswatch here (with proper acknowledgegements)? e.g.,

@luyangkennethluyangkennethMar 20, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that too. The images have straightforward URLs and should be easy to add to our docs. I think it might be reasonable to do that with proper acknowledgements, but I'm not fully sure about that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Themes are very visual things; it's best if we can provide a visual comparison. Also, we should avoid sending our users to external sites as much as possible.

Alternatively, we can duplicate the files in our site (but acknowledge the source). I think they use MIT license which allows duplication.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I'll go ahead with that then!

Comment threaddocs/userGuide/themes.md
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 28a84fc to bda3be3CompareMarch 20, 2019 11:50
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Screenshot 2019-03-20 at 7 43 44 PM

@damithc

Copy link
Copy Markdown
Contributor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Looks good, although the pics blends too well with the page due to white background in both. Perhaps put the whole lot inside a <box> so that the gray background can define the edge of each pic? Just a thought. I'm OK with the current one too.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Nice, yeah I agree it looks better:

Screenshot 2019-03-20 at 8 14 41 PM

@yamgentyamgent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍 Propose a merge commit message?

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@yamgent How about the PR title? :)

@yamgent

Copy link
Copy Markdown
Member

@yamgent How about the PR title? :)

The PR title alone is insufficient in providing the context of the change.

Proposed merge commit message:

Add built-in support for light themes from bootswatch (#745)
To use any custom Bootstrap themes, authors must manually copy over the
theme's .css files to the website's asset folders, and configure the
layout's head.md to use the .css files.
Let's add built-in support for bootswatch light themes, by providing a
"theme" option in site.json, so that authors can just directly specify
the name of the theme in order to use it. For example:
{ "theme": "bootswatch-cerulean"
}

@damithc

Copy link
Copy Markdown
Contributor

Commit message: you can also mention why only light themes are being added.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Whoops I thought you meant just the title of the merge commit. What you proposed sounds good to me!

Re: light themes, maybe we can append this to what you wrote:

Dark themes from Bootswatch are not yet supported because they require
our custom MarkBind components to inherit the Bootstrap styling classes,
to be done in #782.

@yamgentyamgent added this to the v1.21.1 milestone Mar 21, 2019

@Chng-Zhi-XuanChng-Zhi-Xuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Note that #782 should cover not just page-nav and site-nav but also other custom components that currently do not have any bootstrap classes.

E.G. Questions and Modals among many others. They do not allow customisation of how it looks currently (unlike panels or badges). So you have to implement customisation for them if we want everything within MarkBind to support theming.

@yamgent
yamgent merged commit c330dc9 into masterMar 23, 2019
@luyangkenneth
luyangkenneth deleted the support-bootswatch-themes branch March 23, 2019 06:21
@damithc

Copy link
Copy Markdown
Contributor

I'm testing out this feature now. Is it possible to get the navbar to change color too?
Like this:
image

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've investigated this briefly and I think this involves modifying our Navbar custom component to use the bg-primary class, in place of the bg-dark class it currently uses.

For example, if we apply the Journal theme (https://bootswatch.com/journal/), the generated website will have a black navbar (the second one in the list) as opposed to the pink navbar that we see in the thumbnail.


If we change the bootstrap class, the default navbar color will also change, based on the default bootstrap theme.

Using bg-dark (current)

Screenshot 2019-03-25 at 4 37 45 PM

Using bg-primary

Screenshot 2019-03-25 at 4 37 31 PM

But we can probably work around this by modifying how we specify our <navbar> in the user guide's header.md.

Would you like us to move in this direction? / What are your thoughts?

@damithc

Copy link
Copy Markdown
Contributor

Would you like us to move in this direction? / What are your thoughts?

It would be good to take advantage of the different nav bar colors as the navbar plays an important role in making the site look 'different'. It depends on how much effort it will take though. May be senior devs have some thoughts?

@acjh

acjh commented Mar 25, 2019

Copy link
Copy Markdown
Contributor

Let's continue this discussion in #386.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimal support for theming Support for bootswatch themes

6 participants

@luyangkenneth@acjh@damithc@Xenonym@yamgent@Chng-Zhi-Xuan
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add support for light themes from bootswatch - #745

Merged
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes
Mar 23, 2019
Merged

Add support for light themes from bootswatch#745
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes

Conversation

@luyangkenneth

@luyangkennethluyangkenneth commented Mar 2, 2019

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X] New feature

Fixes#547, Fixes#663

High-level approach

The goal here is to enable themes in MarkBind! Building on the discussion in #547, the approach I'm going for is to:

  1. Incorporate bootswatch into the project via its npm package, instead of the other options. This is so that we can manage the dependency via npm, and be able to directly copy the css files without needing to download from a CDN.

  2. During the asset-copying stage of site generation, use the custom bootstrap.min.css of the specified bootswatch theme instead of the default bootstrap file.

  3. Allow users to change the theme of their site by specifying the name of the theme in site.json. At this point, this will be a global setting - no further granularity will be supported e.g. in the frontmatter or layout.

Non-goals

  • Adapt custom MarkBind components to use the overridden bootstrap css (to be done in a separate PR in the future)

Things I would like your input on (edit: these are resolved, thanks everyone!)

I wanted this to get reviewed at its early draft stage so that we have a consensus about what I'll be working on, and how best to go about it. I would appreciate your feedback! Here are some open questions I have:

  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

  2. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

  3. Do you have any concerns about the approach / next steps / anything that I've mentioned so far?

Example of what applying a diferent theme looks like

Screenshot 2019-03-14 at 5 07 42 PM

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Adding everyone as a reviewer to bring this to your attention. Feel free to involve yourself (or not) in the discussion 🙂

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

You can prevent that from happening by (temporarily) downgrading to npm 5.
I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Related: https://github.com/MarkBind/markbind-cli/wiki/Developer-Guide#troubleshooting (#582)

  1. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

If we want to claim theming support, then we should have light/dark versions of almost everything.
We don't want to (and cannot) support all Bootswatch themes nicely.

From your screenshot:

  • code blocks — look fine.
  • highlighting — not shown.
  • colour of the GitHub logo — cannot be changed: https://github.com/logos

@damithc

Copy link
Copy Markdown
Contributor

Shall we support only light themes at first? The need of the hour is for all MarkBind sites not to look exactly the same. That can be achieved with a range of light themes using different primary colors?

@Xenonym

Xenonym commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

@acjh@yamgent It's not so much a bug as it is a change in how package-lock.json is written in npm@6. The official advice is to:

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

colour of the GitHub logo — cannot be changed: github.com/logos

The download for the GitHub mark does have a light version for use on dark backgrounds, (and the GitHub navbar uses it) so a white on dark background logo should be OK.

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor

I didn't say it is a bug. It is an issue as the change is contentious.

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

I disagree. But @yamgent can decide for MarkBind.

@yamgent

Copy link
Copy Markdown
Member

I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Let's stick with npm 5 for now and not risk potentially breaking something.

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 13edb09 to 2beb325CompareMarch 14, 2019 08:33
@luyangkennethluyangkenneth changed the title [RFC] Add support for bootswatch themesAdd support for bootswatch themesMar 14, 2019
@luyangkennethluyangkenneth changed the title Add support for bootswatch themesAdd support for light themes from bootswatchMar 14, 2019
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 094300f to fa4ddf4CompareMarch 14, 2019 09:32
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Thanks for your inputs everyone! We have resolved the npm issue separately in #767, and I've updated this PR description accordingly.

As discussed, we'll only support light themes for now. I'm ready to have the code reviewed - please take a look 🙂 And then after everything is ok, I will proceed with writing the user docs.

@luyangkenneth
luyangkenneth marked this pull request as ready for review March 14, 2019 09:39
Comment threaddocs/site.json Outdated
}
],
"headingIndexingLevel": 6,
"bootswatchTheme": "journal",

@luyangkennethluyangkennethMar 14, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary change, to illustrate what modifying the theme looks like from the user's perspective.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"theme": "bootswatch-journal" is more future proof, in case we add support for other themes?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, yeah that sounds better 👍

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damithc - Updated! How does this look now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Comment threadsrc/Site.js Outdated
'spacelab',
'united',
'yeti',
];

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These correspond to subfolder names within bootswatch's node_modules folder.

Spelling of the themes are double checked with https://bootswatch.com/api/4.json

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from fa4ddf4 to 94d2bbbCompareMarch 14, 2019 10:12
Comment threadsrc/Site.js Outdated
return fs.copyAsync(this.siteAssetsSrcPath, this.siteAssetsDestPath);
const maybeOverrideDefaultBootstrapTheme = () => {
const { theme } = this.siteConfig;
if (!theme || !Object.prototype.hasOwnProperty.call(SUPPORTED_THEMES_PATHS, theme)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this check be simplified to _.has(SUPPORTED_THEMES_PATHS, theme)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, that definitely looks more readable. Done 👍

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 94d2bbb to 9475633CompareMarch 15, 2019 13:07
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Docs are up! 🎉

- [`bootswatch-spacelab`](https://bootswatch.com/spacelab/)
- [`bootswatch-united`](https://bootswatch.com/united/)
- [`bootswatch-yeti`](https://bootswatch.com/yeti/)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use images from bootswatch here (with proper acknowledgegements)? e.g.,

@luyangkennethluyangkennethMar 20, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that too. The images have straightforward URLs and should be easy to add to our docs. I think it might be reasonable to do that with proper acknowledgements, but I'm not fully sure about that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Themes are very visual things; it's best if we can provide a visual comparison. Also, we should avoid sending our users to external sites as much as possible.

Alternatively, we can duplicate the files in our site (but acknowledge the source). I think they use MIT license which allows duplication.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I'll go ahead with that then!

Comment threaddocs/userGuide/themes.md
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 28a84fc to bda3be3CompareMarch 20, 2019 11:50
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Screenshot 2019-03-20 at 7 43 44 PM

@damithc

Copy link
Copy Markdown
Contributor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Looks good, although the pics blends too well with the page due to white background in both. Perhaps put the whole lot inside a <box> so that the gray background can define the edge of each pic? Just a thought. I'm OK with the current one too.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Nice, yeah I agree it looks better:

Screenshot 2019-03-20 at 8 14 41 PM

@yamgentyamgent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍 Propose a merge commit message?

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@yamgent How about the PR title? :)

@yamgent

Copy link
Copy Markdown
Member

@yamgent How about the PR title? :)

The PR title alone is insufficient in providing the context of the change.

Proposed merge commit message:

Add built-in support for light themes from bootswatch (#745)
To use any custom Bootstrap themes, authors must manually copy over the
theme's .css files to the website's asset folders, and configure the
layout's head.md to use the .css files.
Let's add built-in support for bootswatch light themes, by providing a
"theme" option in site.json, so that authors can just directly specify
the name of the theme in order to use it. For example:
{ "theme": "bootswatch-cerulean"
}

@damithc

Copy link
Copy Markdown
Contributor

Commit message: you can also mention why only light themes are being added.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Whoops I thought you meant just the title of the merge commit. What you proposed sounds good to me!

Re: light themes, maybe we can append this to what you wrote:

Dark themes from Bootswatch are not yet supported because they require
our custom MarkBind components to inherit the Bootstrap styling classes,
to be done in #782.

@yamgentyamgent added this to the v1.21.1 milestone Mar 21, 2019

@Chng-Zhi-XuanChng-Zhi-Xuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Note that #782 should cover not just page-nav and site-nav but also other custom components that currently do not have any bootstrap classes.

E.G. Questions and Modals among many others. They do not allow customisation of how it looks currently (unlike panels or badges). So you have to implement customisation for them if we want everything within MarkBind to support theming.

@yamgent
yamgent merged commit c330dc9 into masterMar 23, 2019
@luyangkenneth
luyangkenneth deleted the support-bootswatch-themes branch March 23, 2019 06:21
@damithc

Copy link
Copy Markdown
Contributor

I'm testing out this feature now. Is it possible to get the navbar to change color too?
Like this:
image

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've investigated this briefly and I think this involves modifying our Navbar custom component to use the bg-primary class, in place of the bg-dark class it currently uses.

For example, if we apply the Journal theme (https://bootswatch.com/journal/), the generated website will have a black navbar (the second one in the list) as opposed to the pink navbar that we see in the thumbnail.


If we change the bootstrap class, the default navbar color will also change, based on the default bootstrap theme.

Using bg-dark (current)

Screenshot 2019-03-25 at 4 37 45 PM

Using bg-primary

Screenshot 2019-03-25 at 4 37 31 PM

But we can probably work around this by modifying how we specify our <navbar> in the user guide's header.md.

Would you like us to move in this direction? / What are your thoughts?

@damithc

Copy link
Copy Markdown
Contributor

Would you like us to move in this direction? / What are your thoughts?

It would be good to take advantage of the different nav bar colors as the navbar plays an important role in making the site look 'different'. It depends on how much effort it will take though. May be senior devs have some thoughts?

@acjh

acjh commented Mar 25, 2019

Copy link
Copy Markdown
Contributor

Let's continue this discussion in #386.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimal support for theming Support for bootswatch themes

6 participants

@luyangkenneth@acjh@damithc@Xenonym@yamgent@Chng-Zhi-Xuan
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Add support for light themes from bootswatch - #745

Merged
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes
Mar 23, 2019
Merged

Add support for light themes from bootswatch#745
yamgent merged 8 commits into
masterfrom
support-bootswatch-themes

Conversation

@luyangkenneth

@luyangkennethluyangkenneth commented Mar 2, 2019

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X] New feature

Fixes#547, Fixes#663

High-level approach

The goal here is to enable themes in MarkBind! Building on the discussion in #547, the approach I'm going for is to:

  1. Incorporate bootswatch into the project via its npm package, instead of the other options. This is so that we can manage the dependency via npm, and be able to directly copy the css files without needing to download from a CDN.

  2. During the asset-copying stage of site generation, use the custom bootstrap.min.css of the specified bootswatch theme instead of the default bootstrap file.

  3. Allow users to change the theme of their site by specifying the name of the theme in site.json. At this point, this will be a global setting - no further granularity will be supported e.g. in the frontmatter or layout.

Non-goals

  • Adapt custom MarkBind components to use the overridden bootstrap css (to be done in a separate PR in the future)

Things I would like your input on (edit: these are resolved, thanks everyone!)

I wanted this to get reviewed at its early draft stage so that we have a consensus about what I'll be working on, and how best to go about it. I would appreciate your feedback! Here are some open questions I have:

  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

  2. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

  3. Do you have any concerns about the approach / next steps / anything that I've mentioned so far?

Example of what applying a diferent theme looks like

Screenshot 2019-03-14 at 5 07 42 PM

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Adding everyone as a reviewer to bring this to your attention. Feel free to involve yourself (or not) in the discussion 🙂

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

You can prevent that from happening by (temporarily) downgrading to npm 5.
I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Related: https://github.com/MarkBind/markbind-cli/wiki/Developer-Guide#troubleshooting (#582)

  1. Ideally we want every theme to look polished. But some of the things we're styling (e.g. code blocks, highlighting, colour of the GitHub logo) are fixed, and it might be super tedious to have to come up with custom or light/dark mode versions of everything. So I think there's some ambiguity regarding the scope of this feature, if we want to support all bootswatch themes nicely. Do you have any thoughts on this?

If we want to claim theming support, then we should have light/dark versions of almost everything.
We don't want to (and cannot) support all Bootswatch themes nicely.

From your screenshot:

  • code blocks — look fine.
  • highlighting — not shown.
  • colour of the GitHub logo — cannot be changed: https://github.com/logos

@damithc

Copy link
Copy Markdown
Contributor

Shall we support only light themes at first? The need of the hour is for all MarkBind sites not to look exactly the same. That can be achieved with a range of light themes using different primary colors?

@Xenonym

Xenonym commented Mar 3, 2019

Copy link
Copy Markdown
Contributor
  1. Is npm install bootswatch (no args) the right way to add it as a dependency? I feel uncomfortable seeing all the newly loosened version numbers in package-lock.json, and it wasn't immediately obvious to me how I can prevent that from happening.

Yes. It is an issue with npm 6: npm/npm#20434

@acjh@yamgent It's not so much a bug as it is a change in how package-lock.json is written in npm@6. The official advice is to:

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

colour of the GitHub logo — cannot be changed: github.com/logos

The download for the GitHub mark does have a light version for use on dark backgrounds, (and the GitHub navbar uses it) so a white on dark background logo should be OK.

@acjh

acjh commented Mar 3, 2019

Copy link
Copy Markdown
Contributor

I didn't say it is a bug. It is an issue as the change is contentious.

tl;dr: make sure your whole team is on npm@6 or later, do a single npm install to upgrade your requires fields, and you should stop seeing weird diffs like these.

I disagree. But @yamgent can decide for MarkBind.

@yamgent

Copy link
Copy Markdown
Member

I suggest that developers use npm 5 for now, especially when modifying package-lock.json. @yamgent?

Let's stick with npm 5 for now and not risk potentially breaking something.

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 13edb09 to 2beb325CompareMarch 14, 2019 08:33
@luyangkennethluyangkenneth changed the title [RFC] Add support for bootswatch themesAdd support for bootswatch themesMar 14, 2019
@luyangkennethluyangkenneth changed the title Add support for bootswatch themesAdd support for light themes from bootswatchMar 14, 2019
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch 3 times, most recently from 094300f to fa4ddf4CompareMarch 14, 2019 09:32
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Thanks for your inputs everyone! We have resolved the npm issue separately in #767, and I've updated this PR description accordingly.

As discussed, we'll only support light themes for now. I'm ready to have the code reviewed - please take a look 🙂 And then after everything is ok, I will proceed with writing the user docs.

@luyangkenneth
luyangkenneth marked this pull request as ready for review March 14, 2019 09:39
Comment threaddocs/site.json Outdated
}
],
"headingIndexingLevel": 6,
"bootswatchTheme": "journal",

@luyangkennethluyangkennethMar 14, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary change, to illustrate what modifying the theme looks like from the user's perspective.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"theme": "bootswatch-journal" is more future proof, in case we add support for other themes?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, yeah that sounds better 👍

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damithc - Updated! How does this look now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Comment threadsrc/Site.js Outdated
'spacelab',
'united',
'yeti',
];

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These correspond to subfolder names within bootswatch's node_modules folder.

Spelling of the themes are double checked with https://bootswatch.com/api/4.json

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from fa4ddf4 to 94d2bbbCompareMarch 14, 2019 10:12
Comment threadsrc/Site.js Outdated
return fs.copyAsync(this.siteAssetsSrcPath, this.siteAssetsDestPath);
const maybeOverrideDefaultBootstrapTheme = () => {
const { theme } = this.siteConfig;
if (!theme || !Object.prototype.hasOwnProperty.call(SUPPORTED_THEMES_PATHS, theme)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this check be simplified to _.has(SUPPORTED_THEMES_PATHS, theme)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, that definitely looks more readable. Done 👍

@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 94d2bbb to 9475633CompareMarch 15, 2019 13:07
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Docs are up! 🎉

- [`bootswatch-spacelab`](https://bootswatch.com/spacelab/)
- [`bootswatch-united`](https://bootswatch.com/united/)
- [`bootswatch-yeti`](https://bootswatch.com/yeti/)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use images from bootswatch here (with proper acknowledgegements)? e.g.,

@luyangkennethluyangkennethMar 20, 2019

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that too. The images have straightforward URLs and should be easy to add to our docs. I think it might be reasonable to do that with proper acknowledgements, but I'm not fully sure about that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Themes are very visual things; it's best if we can provide a visual comparison. Also, we should avoid sending our users to external sites as much as possible.

Alternatively, we can duplicate the files in our site (but acknowledge the source). I think they use MIT license which allows duplication.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I'll go ahead with that then!

Comment threaddocs/userGuide/themes.md
@luyangkenneth
luyangkennethforce-pushed the support-bootswatch-themes branch from 28a84fc to bda3be3CompareMarch 20, 2019 11:50
@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Screenshot 2019-03-20 at 7 43 44 PM

@damithc

Copy link
Copy Markdown
Contributor

@damithc I've added the images for easier visual comparison between the themes. How does this look now?

Looks good, although the pics blends too well with the page due to white background in both. Perhaps put the whole lot inside a <box> so that the gray background can define the edge of each pic? Just a thought. I'm OK with the current one too.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Nice, yeah I agree it looks better:

Screenshot 2019-03-20 at 8 14 41 PM

@yamgentyamgent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍 Propose a merge commit message?

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@yamgent How about the PR title? :)

@yamgent

Copy link
Copy Markdown
Member

@yamgent How about the PR title? :)

The PR title alone is insufficient in providing the context of the change.

Proposed merge commit message:

Add built-in support for light themes from bootswatch (#745)
To use any custom Bootstrap themes, authors must manually copy over the
theme's .css files to the website's asset folders, and configure the
layout's head.md to use the .css files.
Let's add built-in support for bootswatch light themes, by providing a
"theme" option in site.json, so that authors can just directly specify
the name of the theme in order to use it. For example:
{ "theme": "bootswatch-cerulean"
}

@damithc

Copy link
Copy Markdown
Contributor

Commit message: you can also mention why only light themes are being added.

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

Whoops I thought you meant just the title of the merge commit. What you proposed sounds good to me!

Re: light themes, maybe we can append this to what you wrote:

Dark themes from Bootswatch are not yet supported because they require
our custom MarkBind components to inherit the Bootstrap styling classes,
to be done in #782.

@yamgentyamgent added this to the v1.21.1 milestone Mar 21, 2019

@Chng-Zhi-XuanChng-Zhi-Xuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Note that #782 should cover not just page-nav and site-nav but also other custom components that currently do not have any bootstrap classes.

E.G. Questions and Modals among many others. They do not allow customisation of how it looks currently (unlike panels or badges). So you have to implement customisation for them if we want everything within MarkBind to support theming.

@yamgent
yamgent merged commit c330dc9 into masterMar 23, 2019
@luyangkenneth
luyangkenneth deleted the support-bootswatch-themes branch March 23, 2019 06:21
@damithc

Copy link
Copy Markdown
Contributor

I'm testing out this feature now. Is it possible to get the navbar to change color too?
Like this:
image

@luyangkenneth

Copy link
Copy Markdown
ContributorAuthor

@damithc I've investigated this briefly and I think this involves modifying our Navbar custom component to use the bg-primary class, in place of the bg-dark class it currently uses.

For example, if we apply the Journal theme (https://bootswatch.com/journal/), the generated website will have a black navbar (the second one in the list) as opposed to the pink navbar that we see in the thumbnail.


If we change the bootstrap class, the default navbar color will also change, based on the default bootstrap theme.

Using bg-dark (current)

Screenshot 2019-03-25 at 4 37 45 PM

Using bg-primary

Screenshot 2019-03-25 at 4 37 31 PM

But we can probably work around this by modifying how we specify our <navbar> in the user guide's header.md.

Would you like us to move in this direction? / What are your thoughts?

@damithc

Copy link
Copy Markdown
Contributor

Would you like us to move in this direction? / What are your thoughts?

It would be good to take advantage of the different nav bar colors as the navbar plays an important role in making the site look 'different'. It depends on how much effort it will take though. May be senior devs have some thoughts?

@acjh

acjh commented Mar 25, 2019

Copy link
Copy Markdown
Contributor

Let's continue this discussion in #386.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimal support for theming Support for bootswatch themes

6 participants

@luyangkenneth@acjh@damithc@Xenonym@yamgent@Chng-Zhi-Xuan