Skip to content

Commit

Permalink
feat(web): prefer hide-ui over hide-ui=true
Browse files Browse the repository at this point in the history
  • Loading branch information
stevapple committed Oct 25, 2024
1 parent 9f3bc63 commit 91548d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions web/src/components/DocumentControlButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ export default function DocumentControlButtons(props: Props): JSX.Element {
url = url.replace(props.version, 'latest')
}

if (shareModalHideUi && !url.includes('?hide-ui=true')) {
const urlObject = URL.parse(url)
if (urlObject !== null) {
urlObject.searchParams.set('hide-ui', 'true')
url = urlObject.toString()
}
if (shareModalHideUi) {
const urlObject = new URL(url)
urlObject.search = 'hide-ui'
url = urlObject.toString()
}

return url
Expand Down
6 changes: 3 additions & 3 deletions web/src/pages/Docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Docs(): JSX.Element {
const hash = useRef(location.hash)

const [version, setVersion] = useState<string>(params.version ?? 'latest')
const [hideUi, setHideUi] = useState<boolean>(searchParams.get('hide-ui') === 'true')
const [hideUi, setHideUi] = useState<boolean>(searchParams.get('hide-ui') === '' || searchParams.get('hide-ui') === 'true')
const [iframeUpdateTrigger, setIframeUpdateTrigger] = useState<number>(0)

// This provides the url for the iframe.
Expand Down Expand Up @@ -99,7 +99,7 @@ export default function Docs(): JSX.Element {
hash: string,
hideUi: boolean
): string => {
return `/${project}/${version}/${encodeURI(page)}${hash}${hideUi ? '?hide-ui=true' : ''}`
return `/${project}/${version}/${encodeURI(page)}${hash}${hideUi ? '?hide-ui' : ''}`
}

const updateUrl = (newVersion: string, hideUi: boolean): void => {
Expand Down Expand Up @@ -159,7 +159,7 @@ export default function Docs(): JSX.Element {
const urlVersion = params.version ?? 'latest'
const urlPage = params['*'] ?? ''
const urlHash = location.hash
const urlHideUi = searchParams.get('hide-ui') === 'true'
const urlHideUi = searchParams.get('hide-ui') === '' || searchParams.get('hide-ui') === 'true'

// update the state to the url params on first loadon
if (urlProject !== project.current) {
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/IframePageNotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface Props {
}

export default function IframeNotFound(props: Props): JSX.Element {
const link = `/${props.project}/${props.version}${props.hideUi ? '?hide-ui=true' : ''}`
const link = `/${props.project}/${props.version}${props.hideUi ? '?hide-ui' : ''}`

return (
<div className={styles['iframe-page-not-found']}>
Expand Down

0 comments on commit 91548d3

Please sign in to comment.