Skip to content

Commit

Permalink
simplify hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubabrzy committed Sep 18, 2023
1 parent a786235 commit 5757de0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
10 changes: 5 additions & 5 deletions faq.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<AccordionItem summary="Is OpenTF going to be a foundation?" open highlight>
<AccordionItem id="foundation" summary="Is OpenTF going to be a foundation?" open highlight>

We strongly prefer joining an existing reputable foundation over creating a
new one. Stay tuned for additional details in the coming week.

</AccordionItem>

<AccordionItem summary="Can anyone pledge?" highlight>
<AccordionItem id="pledge" summary="Can anyone pledge?" highlight>

Under a well-known and widely-accepted license that companies can trus, that
won’t suddenly change in the future, and isn’t subhect to the whims of a singe
Expand All @@ -15,7 +15,7 @@ of a singe vendor.

</AccordionItem>

<AccordionItem summary="I'm a regular Terraform user, and I'm not competing with HashiCorp. Why should I care?">
<AccordionItem id="not-competing-hashicorp" summary="I'm a regular Terraform user, and I'm not competing with HashiCorp. Why should I care?">

How do you know you're not competing with HashiCorp?

Expand All @@ -31,7 +31,7 @@ In short, the BUSL is a poison pill for the entire Terraform community.

</AccordionItem>

<AccordionItem summary="Doesn't forking hurt the whole community? Why take such a brash action?" highlight>
<AccordionItem id="forking" summary="Doesn't forking hurt the whole community? Why take such a brash action?" highlight>

Terraform was under the MPL license for ~9 years. This created an understanding—an implicit contract—that Terraform is open-source and you can use it for just about anything you want. Based on that understanding, tens of thousands of developers adopted the tool and contributed back to it. HashiCorp even had all contributors sign a CLA which explicitly said ([link to the CLA in the Internet Archive as HashiCorp](https://web.archive.org/web/20230610041432/https://www.hashicorp.com/cla) has of course removed this wording):

Expand All @@ -45,7 +45,7 @@ The OpenTF manifesto is about _undoing_ those changes! It's about going back to

</AccordionItem>

<AccordionItem summary="HashiCorp deserves to earn a return on their investment. What's wrong with that?">
<AccordionItem id="hashicorp-investment" summary="HashiCorp deserves to earn a return on their investment. What's wrong with that?">

When any company releases their tool as open source, the contract with the community is always the same: Anyone can use this code, but we the creators hold a privileged position of being at the epicenter of the ecosystem. Vendors then compete to offer the best solution, and the creators enjoy a unique competitive advantage.

Expand Down
13 changes: 9 additions & 4 deletions src/components/Accordion/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,34 @@ type AccordionItemProps = {
summary: string;
open?: boolean;
highlight?: boolean;
id: string
};

const AccordionItem = ({ summary, open, children }: AccordionItemProps) => {
const AccordionItem = ({ summary, open, children, id }: AccordionItemProps) => {
const detailsRef = useRef(null);
const location = useLocation();

const hashEnabled = location.pathname === '/faq'
const handleItemClick = () => {
document.querySelectorAll("details.accordion-item").forEach((item) => {
if (item !== detailsRef.current) {
item.removeAttribute("open");
}
});

if(!hashEnabled) {
return;
}

if (decodeURI(location.hash) === `#${summary}`) {
// Hash at the end disables ability to open automaticaly first FAQ item
window.location.replace(`${location.pathname}#`);
} else {
window.location.replace(`${location.pathname}#${encodeURI(summary)}`);
window.location.replace(`${location.pathname}#${encodeURI(id)}`);
}
};

useEffect(() => {
if (decodeURI(location.hash) === `#${summary}`) {
if (decodeURI(location.hash) === `#${id}` && hashEnabled) {
document.querySelectorAll("details.accordion-item").forEach((item) => {
if (item !== detailsRef.current) {
item.removeAttribute("open");
Expand Down

0 comments on commit 5757de0

Please sign in to comment.