Skip to content

Improved theme settings support #402

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Sep 23, 2022

Conversation

mportiz08
Copy link
Contributor

Bug/issue #, if applicable: 97040358

Summary

This PR updates the existing support for the theme-settings.json file to be more fully featured and capable. This is the Swift-DocC-Render implementation support for my recent forum proposal titled
Customizing the look and feel of Swift-DocC-Render
.

Major Changes:

  • removed default theme-settings.json file since it only existed for pseudo documentation purposes (full OpenAPI spec will be created for Swift-DocC as well as conceptual docs)
  • fixed bugs with overwritten colors not working right when switching between Light/Dark/Auto modes
  • added support for global border-radius override
  • added support for overriding content and code font stacks
  • added support for overriding builtin SVG icons
  • added support for overriding component specific borders of the following elements
    • asides
    • badges
    • buttons
    • code listings
  • added some new colors to make it easier to customize the follow elements:
    • buttons
    • documentation intro
    • tutorials overview page
  • added support for customizing outer border radius of step elements
  • all supported properties of the theme-settings.json file should be specified here (will open PR on Swift-DocC for this soon)

More documentation PRs will be created for the swift-docc repo next to guide users on how to utilize this file.

Dependencies

swiftlang/swift-docc#339 (already merged to Swift-DocC main)

Testing

Steps:

  1. From this branch, run npm run build to build this branch of swift-docc-render
  2. Checkout swift-docc and pull the latest main branch
  3. Extract the example theme-settings.json file and custom article.svg icon from files.zip and copy them into the top level of the documentation catalog for SwiftDocC at Sources/SwiftDocC/SwiftDocC.docc
  4. From the swift-docc repo, run env DOCC_HTML_DIR=/path/to/swift-docc-render/dist bin/preview-docs SwiftDocC
  5. Open http://localhost:8000/documentation/swiftdocc and check that the theme settings are applied as expected
  6. Play around with your own settings and check that there are no regressions if there are no theme settings provided

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran npm test, and it succeeded
  • Updated documentation if necessary

@mportiz08
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@dobromir-hristov dobromir-hristov left a comment

Choose a reason for hiding this comment

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

Awesome work Marcus, just a few questions:

  1. Would we keep the old --colors vs --color naming convention? I think --colors used to come from the initial version of the theme-settings? Or are we just deprecating that for now, without removing support?

@mportiz08
Copy link
Contributor Author

Awesome work Marcus, just a few questions:

  1. Would we keep the old --colors vs --color naming convention? I think --colors used to come from the initial version of the theme-settings? Or are we just deprecating that for now, without removing support?

From an API point of view, I think it should be considered unofficially deprecated. Since none of the implementation for it has been changed, things should continue to work if the plural form is used in the cases where it was previously being used, although ideally those clients using the old form could very simply adopt to the new version. Going forward, I think the singular form would be documented as the correct API. (I went with that version only because it has a 1-1 correlation with the actual CSS property names.)

@mportiz08
Copy link
Contributor Author

I've opened a PR on DocC that adds an API reference for theme-settings.json and a conceptual article to walkthrough examples of using the file: swiftlang/swift-docc#359

Copy link
Contributor

@dobromir-hristov dobromir-hristov left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@marinaaisa marinaaisa left a comment

Choose a reason for hiding this comment

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

Thanks Marcus, this is a great improvement in the way we customise our UI 👏

…-support

Conflicts:
  src/components/Icons/SwiftFileIcon.vue
@mportiz08
Copy link
Contributor Author

@swift-ci test

1 similar comment
@mportiz08
Copy link
Contributor Author

@swift-ci test

There is code in the function to lock the scroll which adds inline
styles to the body element. These styles are removed by clearing out all
the inline styles when the unlock function is called—but also any inline
styles are removed which interferes with the theme settings variables—by
being more explicit about which inline styles are removed, this bug can
be avoided.  Now, only those styles needed for locking/unlocking scroll
are removed when that function is called.
Conflicts:
  src/components/SVGIcon.vue
@mportiz08
Copy link
Contributor Author

@swift-ci test

@mportiz08 mportiz08 merged commit 0089110 into swiftlang:main Sep 23, 2022
@mportiz08 mportiz08 deleted the improve-theme-settings-support branch September 23, 2022 20:48
Sign up for free to 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.

3 participants