Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Redesign Stencila theme and add Wilmore #85

Merged
merged 16 commits into from
Feb 28, 2020
Merged

Redesign Stencila theme and add Wilmore #85

merged 16 commits into from
Feb 28, 2020

Conversation

alex-ketch
Copy link
Collaborator

@alex-ketch alex-ketch commented Feb 27, 2020

This PR makes several changes, fixes, and improvements. Please see the atomic commit messages for the changelog.

Highlights:

  • "Fleshed out" Skeleton theme (a bit ironic, I know 😄)
  • New Stencila theme
  • Tweaked, and re-named old Stencila theme to Wilmore
  • Utility semantic selectors for targeting groups of elements

Closes #70
Closes #73


On another note, there is a pretty severe bug when hot module reloading during development which makes things unworkable. See my comment here, in short on rebuilds, CSS from unrelated files end up in the compiled output. Only on development and only during re-builds, so doesn't affect production releases.

Theres a simple workaround, or you can disablepostcss-combine-media-query during local development.

If the author doesn't get back to us soon, I will fork the repo.

@codecov-io
Copy link

codecov-io commented Feb 27, 2020

Codecov Report

Merging #85 into next will decrease coverage by 3.55%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             next     #85      +/-   ##
=========================================
- Coverage   91.05%   87.5%   -3.56%     
=========================================
  Files           3       4       +1     
  Lines         123     144      +21     
  Branches       35      39       +4     
=========================================
+ Hits          112     126      +14     
- Misses         11      18       +7
Impacted Files Coverage Δ
src/themes/index.ts 100% <ø> (ø) ⬆️
src/util/index.ts 100% <100%> (+0.99%) ⬆️
src/extensions/code/index.ts 61.9% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eddec64...d6ed29e. Read the comment docs.

README.md Outdated

| Selector | Description | Target |
| :------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------- |
| `:--root` | It maps to the root element generated by Encoda. This is done to avoid potential clashes with external stylesheets, and to ensure that Thema only styles semantically annotated content. | `[data-itemscope=root]` |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure what hard dependency there might be on the name from Encoda, but this is very similar to the :root CSS selector. Do you think it's perhaps worth renaming to :--Root to make it less similar?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmmm, during development I did mistakenly type :root by accident once or twice, so do see the concern.
Not sure if it's an implementation detail or if the end-user of this selector would care, but the naming convention of TitleCase vs camelCase depends on if the selector targets a MicroData itemtype vs itemprop.
Do you think clarifying the fact that this selector is supposed to be used in place of :root, and adding a Stylelint warning would be enough to helping catch issues?

Copy link
Member

Choose a reason for hiding this comment

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

I share the concern about similarity between :--root and :root. On one hand it is good because it signals the intent, but on the other, can cause confusion. Regardless of either, it is error prone.

I think Alex's suggestions are good. Let's try them and see if the issue arises again. It's not a painful change if we do need to rename in the future.

/**
* Group element selectors
*/
@custom-selector :--ListTypes :--Article:--root > :--affiliations,:--Collection,:--List,:--references > ol;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you have a view on whether a it should be possible / allowable for a particular theme to define its own custom selectors, or whether you see this as a core thema fuction and so should only happen here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think theme authors should have freedom to define similar selectors on a per theme basis if needed, given that they do so in a way that stays within the boundaries of the project goals (being a good CSS citizen when used in third-party contexts, and avoiding coupling of the selector targets to specific website HTML structure so as to keep the themes useful for multiple authors).

These selectors were the ones that I felt I was reaching for multiple times, and thought they would be useful across themes.

Copy link
Member

Choose a reason for hiding this comment

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

+1 to "theme authors should have freedom to define similar selectors on a per theme basis if needed"

Comment on lines +3 to +5
A theme well suited for consuming long-form manuscripts and prose. Named after Edmond Dantés' alias, [“Lord Wilmore: An
Englishman, and the persona in which Dantès performs random acts of
generosity.“](https://en.wikipedia.org/wiki/The_Count_of_Monte_Cristo#Edmond_Dantès_and_his_aliases)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Love it! Although if a "Mondego" theme appears here I may start to worry 😉

Copy link
Member

@nokome nokome left a comment

Choose a reason for hiding this comment

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

Thanks @alex-ketch. I will push a commit that, I think, better co-locates the selector changes for Prism for you to review.

README.md Outdated Show resolved Hide resolved
README.md Outdated

| Selector | Description | Target |
| :------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------- |
| `:--root` | It maps to the root element generated by Encoda. This is done to avoid potential clashes with external stylesheets, and to ensure that Thema only styles semantically annotated content. | `[data-itemscope=root]` |
Copy link
Member

Choose a reason for hiding this comment

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

I share the concern about similarity between :--root and :root. On one hand it is good because it signals the intent, but on the other, can cause confusion. Regardless of either, it is error prone.

I think Alex's suggestions are good. Let's try them and see if the issue arises again. It's not a painful change if we do need to rename in the future.

src/scripts/selectors.ts Outdated Show resolved Hide resolved
src/scripts/selectors.ts Outdated Show resolved Hide resolved
src/scripts/selectors.ts Outdated Show resolved Hide resolved
/**
* Group element selectors
*/
@custom-selector :--ListTypes :--Article:--root > :--affiliations,:--Collection,:--List,:--references > ol;
Copy link
Member

Choose a reason for hiding this comment

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

+1 to "theme authors should have freedom to define similar selectors on a per theme basis if needed"

The advantage of putting this inside the `code` extension is that it is co-located with other aspects of integrating with PrismJS and is less invasive into other code.

Also adds a test that the DOM mods are doing what is expected.
@nokome
Copy link
Member

nokome commented Feb 28, 2020

@alex-ketch I've push a commit that refactors where the PrimJS-ized selectors go. That seems to work:

image

However, I'm not sure whether the DOM manipulations in the code extension are working.

I don't think we should spend too much time on these workarounds for Prism - it may be more productive to create <stencila-code-fragment> and <stencila-code-block> web components instead - and perhaps use it's tokenization but our own themeable CSS for those tokens.

@alex-ketch
Copy link
Collaborator Author

I've made some followup changes based on the comments @nokome.
Please take a look and merge if everything looks good.

@custom-selector :--CodeBlock [itemtype~='http://schema.stenci.la/CodeBlock'], [itemtype~='http://schema.stenci.la/CodeBlock'] > [class*=language-];

/* prettier-ignore */
@custom-selector :--CodeBlock [itemtype~='http://schema.stenci.la/CodeBlock'], [itemtype~='http://schema.stenci.la/CodeBlock'][class*=language-];
Copy link
Member

Choose a reason for hiding this comment

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

I used [itemtype~='http://schema.stenci.la/CodeBlock'] > [class*=language-] because Encoda puts the class on the <code> element, not it's parent <pre> element. However, it seems that PrismJS decided to 'transfer' the class to the pre. I which case [itemtype~='http://schema.stenci.la/CodeBlock'][class*=language-] is fine and make more sense. Just noting that there is some magic there. All there more reason to move towards Web Components for CodeBlocks and CodeFragments I feel.

@nokome nokome merged commit 93c07a2 into next Feb 28, 2020
@stencila-ci
Copy link
Collaborator

🎉 This PR is included in version 1.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use the itemscope="root" target added by Encoda for storing CSS variables Repurpose current Stencila theme
5 participants