-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add operation content to OpenAPI v2 template (#2618)
* add in components and utils from prev view * fix schema transform execution * implement operation content
- Loading branch information
Showing
20 changed files
with
1,540 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...open-api-docs-view-v2/components/content-with-permalink/content-with-permalink.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
.root { | ||
--permalink-opacity: 0; | ||
|
||
display: flex; | ||
gap: 8px; | ||
align-items: center; | ||
|
||
&:hover { | ||
--permalink-opacity: 1; | ||
} | ||
} | ||
|
||
.permalink { | ||
--icon-color: var(--token-color-foreground-action); | ||
|
||
composes: g-focus-ring-from-box-shadow from global; | ||
border-radius: 6px; | ||
display: flex; | ||
opacity: var(--permalink-opacity); | ||
padding: 4px; | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
transition: opacity 0.2s ease; | ||
} | ||
|
||
&:hover { | ||
--icon-color: var(--token-color-foreground-action-hover); | ||
|
||
opacity: 1; | ||
box-shadow: var(--token-surface-mid-box-shadow); | ||
} | ||
|
||
&:focus-visible { | ||
--icon-color: var(--token-color-foreground-action-active); | ||
|
||
opacity: 1; | ||
background: var(--token-color-surface-faint); | ||
} | ||
} | ||
|
||
.permalinkIcon { | ||
color: var(--permalink-icon-color); | ||
} |
41 changes: 41 additions & 0 deletions
41
src/views/open-api-docs-view-v2/components/content-with-permalink/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
import Link from 'next/link' | ||
import { IconLink16 } from '@hashicorp/flight-icons/svg-react/link-16' | ||
// Types | ||
import type { PropsWithChildren } from 'react' | ||
// Styles | ||
import s from './content-with-permalink.module.css' | ||
import classNames from 'classnames' | ||
|
||
/** | ||
* Renders the provided `children` alongside a permalink `<a />` element. | ||
* | ||
* `ariaLabel` is required to ensure the permalink element has meaningful | ||
* text for screen readers. For simple use cases where `children` is a | ||
* string, the `ariaLabel` can be passed the same value as `children`. | ||
* For more complex use cases, the consumer should determine what text | ||
* would be appropriate to pass to `ariaLabel`. | ||
* | ||
* Note that this component does _not_ handle placing the provided `id` | ||
* in the DOM. It requires the consumer to place the `id` on an appropriate | ||
* element, typically an element rendered in the provided `children`. | ||
*/ | ||
export function ContentWithPermalink({ | ||
id, | ||
ariaLabel, | ||
children, | ||
className, | ||
}: PropsWithChildren<{ id: string; className?: string; ariaLabel: string }>) { | ||
return ( | ||
<div className={classNames(s.root, className)}> | ||
{children} | ||
<Link className={s.permalink} aria-label={ariaLabel} href={`#${id}`}> | ||
<IconLink16 className={s.permalinkIcon} /> | ||
</Link> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/views/open-api-docs-view-v2/components/operation-content/style.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.heading { | ||
composes: hds-typography-display-600 from global; | ||
|
||
/* Ensure we jump to the very top of the page when linking to this item */ | ||
scroll-margin-top: calc(var(--total-scroll-offset) + 999vh); | ||
font-weight: var(--token-typography-font-weight-bold); | ||
color: var(--token-color-foreground-strong); | ||
margin: 0 0 9px 0; | ||
} | ||
|
||
/* HEADER AREA */ | ||
|
||
.methodAndPath { | ||
display: flex; | ||
align-items: flex-start; | ||
gap: 8px; | ||
} | ||
|
||
.method { | ||
text-transform: uppercase; | ||
} | ||
|
||
.path { | ||
composes: hds-typography-code-300 from global; | ||
color: var(--token-color-foreground-primary); | ||
overflow-wrap: break-word; | ||
flex-shrink: 1; | ||
min-width: 0; | ||
} |
Oops, something went wrong.