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

FAQ deep links #171

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
106 changes: 106 additions & 0 deletions packages/react/src/FAQ/FAQ.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,111 @@ export const Default = () => (
</p>
</FAQ.Answer>
</FAQ.Item>
<FAQ.Item>
<FAQ.Question>What&apos;s included in the GitHub for Startups offer?</FAQ.Question>
<FAQ.Answer>
<p>
All GitHub for Startups companies receive up to 20 seats of GitHub Enterprise for free for year one and 50%
off year two. Learn more about the features and capabilities of GitHub Enterprise{' '}
<InlineLink href="https://copilot.github.com/" target="_blank" rel="noreferrer">
here
</InlineLink>
.
</p>
</FAQ.Answer>
</FAQ.Item>
<FAQ.Item>
<FAQ.Question>Who is eligible to apply?</FAQ.Question>
<FAQ.Answer>
<p>Startups who meet the following criteria are eligible to apply for the program:</p>
<ol>
<li>
<Text size="300" variant="muted">
Must be associated with a current GitHub for Startups partner.
</Text>
</li>
<li>
<Text size="300" variant="muted">
Self-funded or funded (Seed-Series A)
</Text>
</li>
<li>
<Text size="300" variant="muted">
Not a current GitHub Enterprise customer
</Text>
</li>
<li>
<Text size="300" variant="muted">
Must not have previously received credits for GitHub Enterprise
</Text>
</li>
</ol>
</FAQ.Answer>
</FAQ.Item>
<FAQ.Item>
<FAQ.Question>What if my startup is not eligible? Are there other resources for me?</FAQ.Question>
<FAQ.Answer>
<p>
If you’re not currently eligible for the GitHub for Startups but would like to try GitHub Enterprise, please
feel to sign up for a trial
<InlineLink href="https://copilot.github.com/" target="_blank" rel="noreferrer">
here
</InlineLink>
.
</p>
</FAQ.Answer>
</FAQ.Item>
<FAQ.Item open id="test">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the drive-by comment @josepmartins - this looked interesting and I was also thinking about this yesterday so hope you don't mind me dropping some feedback here? 😬

I think in practice we'd typically not want to set open attribute by default in the markup, but rather only when required via a "deeplink" url. What do you think about passing a query param, which FAQ component reads, parses and then adds the open attribute to the id of the relevant question?

We can then trigger the opening of the question via the URL like:

mywebsite.com?faq=1 which opens id="1"

Copy link
Contributor Author

@josepmartins josepmartins Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree on not setting the open attribute by default (we should document this). This was more of a test to showcase how the feature "should look", that's why I forced the open attribute.

Not sure about the need for a query param here (or maybe I didn't understand your proposal lol). Wouldn't it be better to use a normal anchor link (mywebsite.com#whats-the-meaning-of-life) that scrolls down to the id of the question and the FAQ component reads, parses, and adds the open attribute to it?

Copy link
Contributor Author

@josepmartins josepmartins Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To illustrate my comment above, made a commit as an example using the location.hash to adjust the open boolean in FAQ:

6b53e62

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌 I love that idea. Glad we're aligned on the optional attribute. I think your approach of doing it without query params makes total sense too. Just bear in mind that the component will need to run any window operations in a useEffect to mitigate SSR constraints, otherwise works for me 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a useHash webhook to handle the window.hash operations, which works pretty fine

hash-FAQ.mov

<FAQ.Question>This is a test of an anchored link to a FAQ item</FAQ.Question>
<FAQ.Answer>
<p>
Any investor, accelerator, or startup support organization is eligible to apply for the GitHub for Startups
program. If you’re not currently eligible for the GitHub for Startups but would like to try GitHub Enterprise,
please feel to sign up for a trial.
</p>
<p>
Any investor, accelerator, or startup support organization is eligible to apply for the GitHub for Startups
program. If you’re not currently eligible for the GitHub for Startups but would like to try GitHub Enterprise,
please feel to sign up for a trial.
</p>
<p>
Any investor, accelerator, or startup support organization is eligible to apply for the GitHub for Startups
program. If you’re not currently eligible for the GitHub for Startups but would like to try GitHub Enterprise,
please feel to sign up for a trial.
</p>
<p>
Any investor, accelerator, or startup support organization is eligible to apply for the GitHub for Startups
program. If you’re not currently eligible for the GitHub for Startups but would like to try GitHub Enterprise,
please feel to sign up for a trial.
</p>
<p>
Any investor, accelerator, or startup support organization is eligible to apply for the GitHub for Startups
program. If you’re not currently eligible for the GitHub for Startups but would like to try GitHub Enterprise,
please feel to sign up for a trial. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae elit
libero, a pharetra augue. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh
ultricies vehicula ut id elit. Nullam id
</p>
<p>
{' '}
<InlineLink href="https://copilot.github.com/" target="_blank" rel="noreferrer">
Apply here
</InlineLink>
.
</p>
</FAQ.Answer>
</FAQ.Item>
</FAQ>
)