Skip to content

Commit

Permalink
Merge pull request #1163 from mi6/develop
Browse files Browse the repository at this point in the history
Resolve conflicts between develop and v3.0.0/develop
  • Loading branch information
GCHQ-Developer-530 authored Oct 16, 2024
2 parents c7371f2 + 3f02d52 commit 12871ea
Showing 1 changed file with 55 additions and 49 deletions.
104 changes: 55 additions & 49 deletions src/content/structured/components/popover-menu/code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tabs:
---

import { IcPopoverMenu, IcMenuItem, IcMenuGroup, IcButton } from "@ukic/react";
import { useRef } from "react";
import { useState } from "react";

## Component demo

Expand Down Expand Up @@ -77,7 +77,7 @@ export const snippets = [
variant="icon"
title="More information"
id="button-1"
onClick={handleClick}
onClick={handlePopoverToggled}
>
<SlottedSVG
slot="icon"
Expand All @@ -91,7 +91,7 @@ export const snippets = [
<path d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z" />
</SlottedSVG>
</IcButton>
<IcPopoverMenu anchor="button-1" aria-label="popover" ref={popoverEl}>
<IcPopoverMenu anchor="button-1" aria-label="popover" open={popoverOpen} onIcPopoverClosed={handlePopoverClosed}>
<IcMenuItem label="Copy code" />
<IcMenuItem label="Paste code" />
<IcMenuItem label="Actions" submenuTriggerFor="actions" />
Expand All @@ -104,10 +104,9 @@ export const snippets = [
long: [
{
language: "Typescript",
snippet: `const popoverEl = useRef(null);
const handleClick = () => {
popoverEl.current.open = !popoverEl.current.open;
};
snippet: `const [popoverOpen, setPopoverOpen] = useState<boolean>(false);
const handlePopoverToggled = () => setPopoverOpen(value => !value);
const handlePopoverClosed = () => setPopoverOpen(false);
return (
<>
{shortCode}
Expand All @@ -116,10 +115,9 @@ return (
},
{
language: "Javascript",
snippet: `const popoverEl = useRef(null);
const handleClick = () => {
popoverEl.current.open = !popoverEl.current.open;
};
snippet: `const [popoverOpen, setPopoverOpen] = useState(false);
const handlePopoverToggled = () => setPopoverOpen(value => !value);
const handlePopoverClosed = () => setPopoverOpen(false);
return (
<>
{shortCode}
Expand All @@ -132,17 +130,16 @@ return (
];

export const DemoPopover = () => {
const popoverEl = useRef(null);
const handleClick = () => {
popoverEl.current.open = !popoverEl.current.open;
};
const [popoverOpen, setPopoverOpen] = useState(false);
const handlePopoverToggled = () => setPopoverOpen((value) => !value);
const handlePopoverClosed = () => setPopoverOpen(false);
return (
<>
<IcButton
variant="icon"
title="More information"
id="button-1"
onClick={handleClick}
onClick={handlePopoverToggled}
>
<svg
slot="icon"
Expand All @@ -156,7 +153,12 @@ export const DemoPopover = () => {
<path d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z" />
</svg>
</IcButton>
<IcPopoverMenu anchor="button-1" aria-label="popover" ref={popoverEl}>
<IcPopoverMenu
anchor="button-1"
aria-label="popover"
open={popoverOpen}
onIcPopoverClosed={handlePopoverClosed}
>
<IcMenuItem label="Copy code" />
<IcMenuItem label="Paste code" />
<IcMenuItem label="Actions" submenuTriggerFor="actions" />
Expand Down Expand Up @@ -258,7 +260,7 @@ export const snippetsButtons = [
variant="icon"
title="More information"
id="button-2"
onClick={handleClick}
onClick={handlePopoverToggled}
>
<SlottedSVG
slot="icon"
Expand All @@ -272,7 +274,7 @@ export const snippetsButtons = [
<path d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z" />
</SlottedSVG>
</IcButton>
<IcPopoverMenu anchor="button-2" aria-label="popover" ref={popoverEl}>
<IcPopoverMenu anchor="button-2" aria-label="popover" open={popoverOpen} onIcPopoverClosed={handlePopoverClosed}>
<IcMenuItem label="Copy" disabled />
<IcMenuItem label="Paste" keyboardShortcut="Cmd + V" />
<IcMenuItem label="Edit" description="This is used to edit the original." />
Expand All @@ -297,10 +299,9 @@ export const snippetsButtons = [
long: [
{
language: "Typescript",
snippet: `const popoverEl = useRef(null);
const handleClick = () => {
popoverEl.current.open = !popoverEl.current.open;
};
snippet: `const [popoverOpen, setPopoverOpen] = useState<boolean>(false);
const handlePopoverToggled = () => setPopoverOpen(value => !value);
const handlePopoverClosed = () => setPopoverOpen(false);
return (
<>
{shortCode}
Expand All @@ -309,10 +310,9 @@ return (
},
{
language: "Javascript",
snippet: `const popoverEl = useRef(null);
const handleClick = () => {
popoverEl.current.open = !popoverEl.current.open;
};
snippet: `const [popoverOpen, setPopoverOpen] = useState(false);
const handlePopoverToggled = () => setPopoverOpen(value => !value);
const handlePopoverClosed = () => setPopoverOpen(false);
return (
<>
{shortCode}
Expand All @@ -325,17 +325,16 @@ return (
];

export const ButtonsPopover = () => {
const popoverEl = useRef(null);
const handleClick = () => {
popoverEl.current.open = !popoverEl.current.open;
};
const [popoverOpen, setPopoverOpen] = useState(false);
const handlePopoverToggled = () => setPopoverOpen((value) => !value);
const handlePopoverClosed = () => setPopoverOpen(false);
return (
<>
<IcButton
variant="icon"
title="More information"
id="button-2"
onClick={handleClick}
onClick={handlePopoverToggled}
>
<svg
slot="icon"
Expand All @@ -349,7 +348,12 @@ export const ButtonsPopover = () => {
<path d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z" />
</svg>
</IcButton>
<IcPopoverMenu anchor="button-2" aria-label="popover" ref={popoverEl}>
<IcPopoverMenu
anchor="button-2"
aria-label="popover"
open={popoverOpen}
onIcPopoverClosed={handlePopoverClosed}
>
<IcMenuItem label="Copy" disabled />
<IcMenuItem label="Paste" keyboardShortcut="Cmd + V" />
<IcMenuItem
Expand Down Expand Up @@ -438,7 +442,7 @@ export const snippetsGroups = [
variant="icon"
title="More information"
id="button-3"
onClick={handleClick}
onClick={handlePopoverToggled}
>
<SlottedSVG
slot="icon"
Expand All @@ -452,7 +456,7 @@ export const snippetsGroups = [
<path d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z" />
</SlottedSVG>
</IcButton>
<IcPopoverMenu anchor="button-3" aria-label="popover" ref={popoverEl}>
<IcPopoverMenu anchor="button-3" aria-label="popover" open={popoverOpen} onIcPopoverClosed={handlePopoverClosed}>
<IcMenuGroup label="Edit options">
<IcMenuItem label="Copy" disabled />
<IcMenuItem label="Paste" keyboardShortcut="Cmd + V" />
Expand All @@ -465,10 +469,9 @@ export const snippetsGroups = [
long: [
{
language: "Typescript",
snippet: `const popoverEl = useRef<HTMLIcPopoverMenuElement | null>(null);
const handleClick = () => {
popoverEl.current.open = !popoverEl.current.open;
};
snippet: `const [popoverOpen, setPopoverOpen] = useState<boolean>(false);
const handlePopoverToggled = () => setPopoverOpen(value => !value);
const handlePopoverClosed = () => setPopoverOpen(false);
return (
<>
{shortCode}
Expand All @@ -477,10 +480,9 @@ return (
},
{
language: "Javascript",
snippet: `const popoverEl = useRef(null);
const handleClick = () => {
popoverEl.current.open = !popoverEl.current.open;
};
snippet: `const [popoverOpen, setPopoverOpen] = useState(false);
const handlePopoverToggled = () => setPopoverOpen(value => !value);
const handlePopoverClosed = () => setPopoverOpen(false);
return (
<>
{shortCode}
Expand All @@ -493,17 +495,16 @@ return (
];

export const GroupsPopover = () => {
const popoverEl = useRef(null);
const handleClick = () => {
popoverEl.current.open = !popoverEl.current.open;
};
const [popoverOpen, setPopoverOpen] = useState(false);
const handlePopoverToggled = () => setPopoverOpen((value) => !value);
const handlePopoverClosed = () => setPopoverOpen(false);
return (
<>
<IcButton
variant="icon"
title="More information"
id="button-3"
onClick={handleClick}
onClick={handlePopoverToggled}
>
<svg
slot="icon"
Expand All @@ -517,7 +518,12 @@ export const GroupsPopover = () => {
<path d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z" />
</svg>
</IcButton>
<IcPopoverMenu anchor="button-3" aria-label="popover" ref={popoverEl}>
<IcPopoverMenu
anchor="button-3"
aria-label="popover"
open={popoverOpen}
onIcPopoverClosed={handlePopoverClosed}
>
<IcMenuGroup label="Edit options">
<IcMenuItem label="Copy" disabled />
<IcMenuItem label="Paste" keyboardShortcut="Cmd + V" />
Expand Down

0 comments on commit 12871ea

Please sign in to comment.