Code Monkey home page Code Monkey logo

Comments (9)

joshtemple avatar joshtemple commented on May 18, 2024 2

That's okay, I had some suggestions for making the theming more consistent with Docusaurus but I'm realizing it's probably better for me to submit those as pull requests here rather than customizing my own.

from redocusaurus.

rohit-gohri avatar rohit-gohri commented on May 18, 2024 1

You can already override primaryColor, just pass it in the theme options. See example here:

theme: {
primaryColor: '#1890ff',
redocOptions: { hideDownloadButton: false },
},

from redocusaurus.

rohit-gohri avatar rohit-gohri commented on May 18, 2024

Not in redocOptions because then there would be no point of this plugin, it's supposed to provide compatibility with docusaurus theme and dark mode. But you can make your own ApiDoc component and specify that to be used by the plugin:
https://github.com/rohit-gohri/redocusaurus/tree/main/packages/docusaurus-plugin-redoc#apidoccomponent-default-themeapidoc

If you want then I can export the getThemeOptions helper directly so you can make your own theme with Dark mode support?

from redocusaurus.

rohit-gohri avatar rohit-gohri commented on May 18, 2024

That would be great

from redocusaurus.

bash83 avatar bash83 commented on May 18, 2024

@joshtemple any luck with the PR? I saw you had a PR moving the font weight around but not about overriding the theme.

@rohit-gohri You seem to be stripping the "theme" property from the redocOptions in "/docusaurus-theme-redoc/src/index.ts". Is there a way to make it optional for the user to either specify the "primaryColor" or provide a baseTheme object?

I just spent hours trying to set things up on my machine to create a PR but failed miserably to setup my environment (quite a noob when it comes to TS, node, and docusaurus).

(trying to implement something similar to https://davidgoss.co/blog/api-documentation-redoc-docusaurus/)

from redocusaurus.

rohit-gohri avatar rohit-gohri commented on May 18, 2024

Let me know if this solves your problem @bash83, if not then I'll try to add a baseTheme option

from redocusaurus.

bash83 avatar bash83 commented on May 18, 2024

@rohit-gohri I’m actually trying to override the font but figured why not allow user to override any value (I know this might complicate things with dark/light theme but it’s on user to sort it out)

from redocusaurus.

rohit-gohri avatar rohit-gohri commented on May 18, 2024

If you want to override all the values you can just swizzle the component and customize everything, it's just a React component:

npm run swizzle -- docusaurus-theme-redoc Redoc --danger

Let me know if you face any problems with that.

You can also just directly specify your own component with the apiDocComponent option.

from redocusaurus.

rohit-gohri avatar rohit-gohri commented on May 18, 2024

Swizzle now works without --danger flag:

JSX Component:

yarn docusaurus swizzle docusaurus-theme-redoc Redoc

TSX Component:

yarn docusaurus swizzle docusaurus-theme-redoc Redoc --typescript

I have abstracted away the theme merging logic out of the component, so customizing them should be more straightforward now:

const {
lightTheme,
darkTheme,
redocOptions = null,
} = usePluginData<GlobalData>('docusaurus-theme-redoc');
const theme = isDarkTheme ? darkTheme : lightTheme;

You get two theme configs from plugin data: lightTheme and darkTheme, you can just merge this over your custom baseTheme before passing it to Redoc

from redocusaurus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.