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

Enhancement : hide edit this on github #1114

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions components/DocsHelp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

interface DocsHelpProps {
markdownFile?: string;
isVisible?: boolean;
}

export function DocsHelp({ markdownFile }: DocsHelpProps) {
export function DocsHelp({ markdownFile, isVisible = true }: DocsHelpProps) {
const router = useRouter();
const path = encodeURIComponent(router.pathname);
const [isFormOpen, setIsFormOpen] = useState(false);
Expand Down Expand Up @@ -296,28 +297,30 @@
type of contribution!
</p>
</div>
<div className='my-4 text-[14px]'>
<a
target='_blank'
rel='noreferrer'
className='px-[16px] py-[8px] cursor-pointer border-solid border-[#aaaaaa] border rounded-md hover:bg-gray-200 dark:hover:bg-gray-600'
href={`https://github.com/json-schema-org/website/blob/main/pages${markdownFile ? (markdownFile === '_indexPage' ? extractPathWithoutFragment(router.asPath) + '/_index.md' : extractPathWithoutFragment(router.asPath) + '.md') : `/${path}/index.page.tsx`}`}
data-test='edit-on-github-link'
>
<svg
className='inline-block select-none align-text-bottom mr-1'
aria-hidden='true'
role='img'
viewBox='0 0 16 16'
width='16'
height='16'
fill='currentColor'
{isVisible ? (
<div className='my-4 text-[14px]'>
<a
target='_blank'
rel='noreferrer'
className='px-[16px] py-[8px] cursor-pointer border-solid border-[#aaaaaa] border rounded-md hover:bg-gray-200 dark:hover:bg-gray-600'
href={`https://github.com/json-schema-org/website/blob/main/pages${markdownFile ? (markdownFile === '_indexPage' ? extractPathWithoutFragment(router.asPath) + '/_index.md' : extractPathWithoutFragment(router.asPath) + '.md') : `/${path}/index.page.tsx`}`}
data-test='edit-on-github-link'
>
<path d='M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z' />
</svg>
Edit this page on Github
</a>
</div>
<svg
className='inline-block select-none align-text-bottom mr-1'
aria-hidden='true'
role='img'
viewBox='0 0 16 16'
width='16'
height='16'
fill='currentColor'
>
<path d='M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z' />
</svg>
Edit this page on Github
</a>
</div>
) : null}

Check warning on line 323 in components/DocsHelp.tsx

View check run for this annotation

Codecov / codecov/patch

components/DocsHelp.tsx#L323

Added line #L323 was not covered by tests
<div className='my-2 text-[14px]'>
<a
target='_blank'
Expand Down
2 changes: 1 addition & 1 deletion pages/tools/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export default function ToolingPage({
setTransform={setTransform}
/>

<DocsHelp />
<DocsHelp isVisible={false} />
</main>
</div>
</div>
Expand Down
Loading