Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Feat: Made the mounting point id configurable. #1050

Merged

Conversation

manatok
Copy link
Contributor

@manatok manatok commented Jul 12, 2018

By default RSG binds to a div with an id of rsg-root with no way of overriding this. We needed to import multiple RSG bundle files into our work documentation site and as such needed to be able to specify the id of the element we wanted the bundles to bind to.

In your styleguide.config.js you can now specify an optional mountPointId to specify the id of the DOM element you want the app to bind to. It will default to the existing rsg-root if not specified.

I have tried to add some tests but might need some guidance here to make sure I am on the right track.

@codecov-io
Copy link

codecov-io commented Jul 12, 2018

Codecov Report

Merging #1050 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted Files Coverage Δ
loaders/styleguide-loader.js 100% <ø> (ø) ⬆️
scripts/schemas/config.js 88.23% <ø> (ø) ⬆️
scripts/make-webpack-config.js 95.45% <ø> (ø) ⬆️
src/rsg-components/Editor/Editor.js 100% <0%> (ø) ⬆️
...rc/rsg-components/StyleGuide/StyleGuideRenderer.js 100% <0%> (ø) ⬆️
src/rsg-components/StyleGuide/StyleGuide.js 85.71% <0%> (ø) ⬆️
src/rsg-components/Editor/EditorLoaderRenderer.js 100% <0%> (ø) ⬆️
src/rsg-components/Version/VersionRenderer.js 100% <0%> (ø)

@sapegin
Copy link
Member

sapegin commented Jul 13, 2018

Could you elaborate a bit on your use case? I'm not against adding this option, but it sounds a bit weird anyway ;-)

@manatok
Copy link
Contributor Author

manatok commented Jul 13, 2018

We have an open source documentation tool (http://presidium.spandigital.net/) that serves .md files as static html pages. We have been working on a number of plugins to pull content into presidium (javadocs, swagger definitions etc) and we are currently adding a plugin for react-styleguidist.

Each article in presidium lives in it's own .md file, which is then linked to the navigation and allows users to interact with it (e.g adding comments). In order to achieve this with RSG, so that it fits in nicely with presidium, our plugin runs RSG against each component separately, so that we can generate a separate bundle and .md per component. As a result, we need to embed multiple components on one page.

Copy link
Member

@sapegin sapegin left a comment

Choose a reason for hiding this comment

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

Sounds good! I've left a few minor comment.


Type: `string`, defaults: `rsg-root`

The id of the DOM element that React-Styleguidist mounts.
Copy link
Member

Choose a reason for hiding this comment

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

id → ID
React-Styleguidist → Styleguidist

@@ -27,7 +27,7 @@ module.exports = function(config, env) {
const htmlPluginOptions = {
context: Object.assign({}, templateContext, {
title: config.title,
container: 'rsg-root',
container: config.mountPointId || 'rsg-root',
Copy link
Member

Choose a reason for hiding this comment

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

You already have a default value from the config schema, so you don't need || here.

@sapegin sapegin added this to the 7.2.0 milestone Jul 18, 2018
@bluetidepro bluetidepro merged commit bfc0382 into styleguidist:master Aug 7, 2018
bluetidepro added a commit that referenced this pull request Aug 7, 2018
## New features

* Add custom component display names ([#933](#933))

```
module.exports = {
  updateDocs(docs) {
    if (docs && docs.displayName) {
      docs.visibleName = docs.displayName.toLowerCase()
    }
    return docs
  }
}
```

* Made the mounting point id configurable. ([#1050](#1050))
bluetidepro added a commit that referenced this pull request Aug 7, 2018
## New features

* Add custom component display names ([#933](#933))

```
module.exports = {
  updateDocs(docs) {
    if (docs && docs.displayName) {
      docs.visibleName = docs.displayName.toLowerCase()
    }
    return docs
  }
}
```

* Made the mounting point id configurable. ([#1050](#1050))

## Bug fixes

* Cypress failing test ([#1077](#1077))
@styleguidist-bot
Copy link
Collaborator

🎉 This PR is included in version 7.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

sapegin pushed a commit that referenced this pull request Aug 9, 2018
* Feat: Made the mounting point id configurable.
* Removed default container name.
* Removed nonsensical test.
valentyn90 pushed a commit to valentyn90/React-Styleguidist that referenced this pull request Oct 28, 2021
## New features

* Add custom component display names ([#933](styleguidist/react-styleguidist#933))

```
module.exports = {
  updateDocs(docs) {
    if (docs && docs.displayName) {
      docs.visibleName = docs.displayName.toLowerCase()
    }
    return docs
  }
}
```

* Made the mounting point id configurable. ([#1050](styleguidist/react-styleguidist#1050))
valentyn90 pushed a commit to valentyn90/React-Styleguidist that referenced this pull request Oct 28, 2021
## New features

* Add custom component display names ([#933](styleguidist/react-styleguidist#933))

```
module.exports = {
  updateDocs(docs) {
    if (docs && docs.displayName) {
      docs.visibleName = docs.displayName.toLowerCase()
    }
    return docs
  }
}
```

* Made the mounting point id configurable. ([#1050](styleguidist/react-styleguidist#1050))

## Bug fixes

* Cypress failing test ([#1077](styleguidist/react-styleguidist#1077))
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.

5 participants