Repository: enzonotario/vitepress-openapi
Pull request #74 (2024-10-08 01:55:20)

change(sidebar style)!: match VitePress default style
# Description

Changes de style of SidebarItems to match the default VitePress style. If anyone prefers the previous style, can create a `style.css` file and import it after `import 'vitepress-openapi/dist/style.css'`, with the following styles:

```
.VPSidebarItem:has(.OASidebarItem) .is-link:hover, .VPSidebarItem:has(.OASidebarItem) .is-active {
    @apply bg-gray-200 text-gray-900 dark:bg-gray-800 dark:text-gray-100 rounded;
}
.VPSidebarItem:has(.OASidebarItem) .is-link {
    @apply text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-800 rounded;
}
.VPSidebarItem:has(.OASidebarItem) .is-active .OASidebarItem-text {
    @apply font-semibold;
}
.OASidebarItem-text {
    @apply truncate max-w-[170px] text-gray-800 dark:text-gray-100;
}
```

## Related issues/external references


## Types of changes

- Breaking change
- Style


vercel[bot]: [vc]: #W2YMb7Ze3XmcFIHnhC3TfxMCm09Ei8MnfRyMwzpzaFM=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJ2aXRlcHJlc3Mtb3BlbmFwaSIsImxpdmVGZWVkYmFjayI6eyJyZXNvbHZlZCI6MCwidW5yZXNvbHZlZCI6MCwidG90YWwiOjAsImxpbmsiOiJ2aXRlcHJlc3Mtb3BlbmFwaS1naXQtZmVhdHVyZS1zaWRlYmFyLWVuem8tbm90YXJpb3MtcHJvamVjdHMudmVyY2VsLmFwcCJ9LCJpbnNwZWN0b3JVcmwiOiJodHRwczovL3ZlcmNlbC5jb20vZW56by1ub3Rhcmlvcy1wcm9qZWN0cy92aXRlcHJlc3Mtb3BlbmFwaS9HazhlWjVGWFFKUlFLZVhDdm9Ta0drQnZXMVRYIiwicHJldmlld1VybCI6InZpdGVwcmVzcy1vcGVuYXBpLWdpdC1mZWF0dXJlLXNpZGViYXItZW56by1ub3Rhcmlvcy1wcm9qZWN0cy52ZXJjZWwuYXBwIiwibmV4dENvbW1pdFN0YXR1cyI6IkRFUExPWUVEIn1dfQ==
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Comments | Updated (UTC) |
| :--- | :----- | :------ | :------- | :------ |
| **vitepress-openapi** | ✅ Ready ([Inspect](https://vercel.com/enzo-notarios-projects/vitepress-openapi/Gk8eZ5FXQJRQKeXCvoSkGkBvW1TX)) | [Visit Preview](https://vercel.live/open-feedback/vitepress-openapi-git-feature-sidebar-enzo-notarios-projects.vercel.app?via=pr-comment-visit-preview-link&passThrough=1) | 💬 [**Add feedback**](https://vercel.live/open-feedback/vitepress-openapi-git-feature-sidebar-enzo-notarios-projects.vercel.app?via=pr-comment-feedback-link) | Oct 8, 2024 1:55am |


coderabbitai[bot]: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- This is an auto-generated comment: review in progress by coderabbit.ai -->

> [!NOTE]
> Currently processing new changes in this PR. This may take a few minutes, please wait...
> 
> 	<details>
> <summary>📥 Commits</summary>
> 
> Files that changed from the base of the PR and between 375b6d1dae3ce5c426e1c9c2a7579e1968f9a291 and 79352ba1343d6fce6c260b32cd86d4268ec8779c.
> 
> </details>
> 
> <details>
> <summary>📒 Files selected for processing (3)</summary>
> 
> * src/composables/useSidebar.ts (1 hunks)
> * src/style.css (1 hunks)
> * test/composables/useSidebar.test.ts (1 hunks)
> 
> </details>
> 
> 	```ascii
>  ____________________________________________________________________________________________________________________________________________________________
> < Don't program by coincidence. Rely only on reliable things. Beware of accidental complexity, and don't confuse a happy coincidence with a purposeful plan. >
>  ------------------------------------------------------------------------------------------------------------------------------------------------------------
>   \
>    \   \
>         \ /\
>         ( )
>       .( o ).
> ```

<!-- end of auto-generated comment: review in progress by coderabbit.ai --><!-- tips_start -->

---

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
pkg-pr-new[bot]: 
[Open in Stackblitz](https://pkg.pr.new/template/b7fde4a4-3499-43b6-b000-bf128ba2320f)


```
pnpm add https://pkg.pr.new/vitepress-openapi@74
```


```
pnpm add https://pkg.pr.new/vitepress-openapi@74
```


_commit: <a href="https://github.com/enzonotario/vitepress-openapi/runs/31208891589"><code>79352ba</code></a>_


Patch:
diff --git a/src/composables/useSidebar.ts b/src/composables/useSidebar.ts
index f48a185..f90e430 100644
--- a/src/composables/useSidebar.ts
+++ b/src/composables/useSidebar.ts
@@ -31,9 +31,9 @@ export function useSidebar({
   const openapi = OpenApi({ spec: options.spec })
 
   function sidebarItemTemplate(method: string, title: string) {
-    return `<span class="OASidebarItem">
+    return `<span class="OASidebarItem group/oaSidebarItem">
         <span class="OASidebarItem-badge OAMethodBadge--${method.toLowerCase()}">${method.toUpperCase()}</span>
-        <span class="OASidebarItem-text">${title}</span>
+        <p class="OASidebarItem-text text">${title}</p>
       </span>`
   }
 
diff --git a/src/style.css b/src/style.css
index 6955284..681efcd 100644
--- a/src/style.css
+++ b/src/style.css
@@ -60,48 +60,62 @@
   }
 }
 
-.VPSidebarItem:has(.OASidebarItem) .is-link:hover {
-  @apply bg-gray-200 text-gray-900 dark:bg-gray-800 dark:text-gray-100 rounded;
-}
-.VPSidebarItem:has(.OASidebarItem) .is-link {
-  @apply text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-800 rounded;
-}
-.VPSidebarItem:has(.OASidebarItem) .is-active {
-  @apply bg-gray-200 text-gray-900 dark:bg-gray-800 dark:text-gray-100 rounded;
-}
-.VPSidebarItem:has(.OASidebarItem) .is-active .OASidebarItem-text {
-  @apply font-semibold;
-}
+/**
+  Sidebar
+ */
+
 .OASidebarItem {
   @apply flex flex-row items-center w-full px-2 space-x-1;
 }
 .OASidebarItem-badge {
   @apply px-1 py-0.5 text-xs rounded;
 }
-.OASidebarItem-text {
-  @apply truncate max-w-[170px] text-gray-800 dark:text-gray-100;
-}
+
+/**
+  Method badges
+ */
 
 .OAMethodBadge--get {
-  @apply bg-green-200 text-green-800 hover:bg-green-300 dark:bg-green-800 dark:text-green-200 dark:hover:bg-green-700;
+  @apply bg-green-200 text-green-800
+    group-hover/oaSidebarItem:bg-green-300 hover:bg-green-300
+    dark:bg-green-800 dark:text-green-200
+    dark:group-hover/oaSidebarItem:bg-green-700 dark:hover:bg-green-700;
 }
 .OAMethodBadge--post {
-  @apply bg-blue-200 text-blue-800 hover:bg-blue-300 dark:bg-blue-800 dark:text-blue-200 dark:hover:bg-blue-700;
+  @apply bg-blue-200 text-blue-800
+    group-hover/oaSidebarItem:bg-blue-300 hover:bg-blue-300
+    dark:bg-blue-800 dark:text-blue-200
+    dark:group-hover/oaSidebarItem:bg-blue-700 dark:hover:bg-blue-700;
 }
 .OAMethodBadge--put {
-  @apply bg-yellow-200 text-yellow-800 hover:bg-yellow-300 dark:bg-yellow-800 dark:text-yellow-200 dark:hover:bg-yellow-700;
+  @apply bg-yellow-200 text-yellow-800
+    group-hover/oaSidebarItem:bg-yellow-300 hover:bg-yellow-300
+    dark:bg-yellow-800 dark:text-yellow-200
+    dark:group-hover/oaSidebarItem:bg-yellow-700 dark:hover:bg-yellow-700;
 }
 .OAMethodBadge--delete {
-  @apply bg-red-200 text-red-800 hover:bg-red-300 dark:bg-red-800 dark:text-red-200 dark:hover:bg-red-700;
+  @apply bg-red-200 text-red-800
+    group-hover/oaSidebarItem:bg-red-300 hover:bg-red-300
+    dark:bg-red-800 dark:text-red-200
+    dark:group-hover/oaSidebarItem:bg-red-700 dark:hover:bg-red-700;
 }
 .OAMethodBadge--patch {
-  @apply bg-purple-200 text-purple-800 hover:bg-purple-300 dark:bg-purple-800 dark:text-purple-200 dark:hover:bg-purple-700;
+  @apply bg-purple-200 text-purple-800
+    group-hover/oaSidebarItem:bg-purple-300 hover:bg-purple-300
+    dark:bg-purple-800 dark:text-purple-200
+    dark:group-hover/oaSidebarItem:bg-purple-700 dark:hover:bg-purple-700;
 }
 .OAMethodBadge--options {
-  @apply bg-indigo-200 text-indigo-800 hover:bg-indigo-300 dark:bg-indigo-800 dark:text-indigo-200 dark:hover:bg-indigo-700;
+  @apply bg-indigo-200 text-indigo-800
+    group-hover/oaSidebarItem:bg-indigo-300 hover:bg-indigo-300
+    dark:bg-indigo-800 dark:text-indigo-200
+    dark:group-hover/oaSidebarItem:bg-indigo-700 dark:hover:bg-indigo-700;
 }
 .OAMethodBadge--head {
-  @apply bg-pink-200 text-pink-800 hover:bg-pink-300 dark:bg-pink-800 dark:text-pink-200 dark:hover:bg-pink-700;
+  @apply bg-pink-200 text-pink-800
+    group-hover/oaSidebarItem:bg-pink-300 hover:bg-pink-300
+    dark:bg-pink-800 dark:text-pink-200
+    dark:group-hover/oaSidebarItem:bg-pink-700 dark:hover:bg-pink-700;
 }
 
 /**


Test patch:
diff --git a/test/composables/useSidebar.test.ts b/test/composables/useSidebar.test.ts
index eb09ac7..3992c5d 100644
--- a/test/composables/useSidebar.test.ts
+++ b/test/composables/useSidebar.test.ts
@@ -7,9 +7,9 @@ describe('useSidebar', () => {
 
   it('creates a sidebar item template', () => {
     const result = useSidebar().sidebarItemTemplate('get', 'GET /users With a Long Title')
-    expect(result).toBe(`<span class="OASidebarItem">
+    expect(result).toBe(`<span class="OASidebarItem group/oaSidebarItem">
         <span class="OASidebarItem-badge OAMethodBadge--get">GET</span>
-        <span class="OASidebarItem-text">GET /users With a Long Title</span>
+        <p class="OASidebarItem-text text">GET /users With a Long Title</p>
       </span>`)
   })