-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
packages/landingpage/app/[lang]/library/patterns/_components/copy-button-react.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,68 @@ | ||
import React, { useState } from 'react'; | ||
import { InoIcon, InoPopover } from '@inovex.de/elements-react'; | ||
import styles from './preview-box.module.scss'; | ||
|
||
interface CopyButtonProps { | ||
rawCode: string; | ||
copyIconId: string; | ||
} | ||
|
||
const ACCORDION_REACT_CODE = ` | ||
<div className="max-w-6xl p-6 bg-white "> | ||
<h3 className="text-3xl header-d3 mb-8 text-inovex-primary">FAQs</h3> | ||
<InoMeetupAccordion accordionTitle="What are Web Components?"> | ||
Web Components are a set of web platform APIs that allow you to create new custom, reusable, encapsulated HTML tags to use in web pages and web apps. They are based on existing web standards and work across modern browsers. | ||
</InoMeetupAccordion> | ||
<InoMeetupAccordion accordionTitle="How can I use Web Components in my project?"> | ||
You can use Web Components in any project by importing them into your HTML file or JavaScript framework. For example, with the inovex Elements library, you can install it using npm and then import the components you need in your React, Angular, or Vue.js project. | ||
</InoMeetupAccordion> | ||
<InoMeetupAccordion accordionTitle="What are the main advantages of using Web Components?"> | ||
The main advantages of Web Components include reusability across different frameworks, encapsulation of styles and functionality, and the ability to create custom elements that work seamlessly with existing HTML, CSS, and JavaScript. | ||
</InoMeetupAccordion> | ||
<InoMeetupAccordion accordionTitle="How do I style Web Components?"> | ||
With inovex Elements, you can use CSS variables like --ino-input-line-color to customize the appearance of components. | ||
</InoMeetupAccordion> | ||
<InoMeetupAccordion accordionTitle="Can I use Web Components with React?"> | ||
We provide a React wrapper, making it easy to use our web components in React projects with a familiar syntax. | ||
</InoMeetupAccordion> | ||
<InoMeetupAccordion accordionTitle="What are slots in Web Components?"> | ||
Slots are a feature of Web Components that allow you to define placeholders in your component that can be filled with custom content. This makes components more flexible and customizable. | ||
</InoMeetupAccordion> | ||
</div> | ||
`; | ||
|
||
export default function CopyButtonReact({ rawCode, copyIconId }: CopyButtonProps) { | ||
const [wasCopied, setWasCopied] = useState(false); | ||
|
||
const handleIconClick = () => { | ||
setWasCopied(true); | ||
setTimeout(() => { | ||
setWasCopied(false); | ||
}, 3000); | ||
|
||
if (navigator.clipboard) { | ||
navigator.clipboard.writeText(ACCORDION_REACT_CODE); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
{wasCopied ? ( | ||
<InoIcon icon="checkmark" className={styles.copyIcon} onClick={handleIconClick} /> | ||
) : ( | ||
<img src="/react.svg" style={{ width: 20 }} onClick={handleIconClick} /> | ||
)} | ||
<InoPopover controlled={true} visible={wasCopied} for={copyIconId} trigger="click" placement="top"> | ||
<div className={styles.popover}> | ||
<span className="body-s">Copied!</span> | ||
</div> | ||
</InoPopover> | ||
</> | ||
); | ||
} |
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