Skip to content

Commit

Permalink
reusable eduidbutton format for show or copy toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
cartja committed Nov 8, 2024
1 parent 6c151e8 commit 1da1b95
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
9 changes: 3 additions & 6 deletions src/components/Common/CopyToClipboardButton.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import EduIDButton from "components/Common/EduIDButton";
import { forwardRef, useState } from "react";
import { FormattedMessage } from "react-intl";

Expand All @@ -17,16 +18,12 @@ export const CopyToClipboardButton = forwardRef((props, ref: any) => {
}

return (
<button
className="show-hide-button"
onClick={copyToClipboard}
aria-label={tooltipCopied ? "Copied!" : "Copy to clipboard"}
>
<EduIDButton className="txt-toggle-btn" buttonstyle="link" size="sm" onClick={copyToClipboard}>
{tooltipCopied ? (
<FormattedMessage defaultMessage="COPIED" description="copied button label" />
) : (
<FormattedMessage defaultMessage="COPY" description="copy button label" />
)}
</button>
</EduIDButton>
);
});
10 changes: 6 additions & 4 deletions src/components/Common/PasswordInput.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import EduIDButton from "components/Common/EduIDButton";
import React, { useState } from "react";
import { FieldRenderProps, Field as FinalField } from "react-final-form";
import { FormattedMessage, useIntl } from "react-intl";
Expand Down Expand Up @@ -68,10 +69,11 @@ export function PasswordInputElement(props: InputProps): JSX.Element {
autoFocus={props.autoFocus}
/>

<button
type="button"
<EduIDButton
className="txt-toggle-btn"
buttonstyle="link"
size="sm"
aria-label={showPassword ? "hide password" : "show password"}
className="show-hide-button"
onClick={toggleShowPassword}
tabIndex={-1}
>
Expand All @@ -80,7 +82,7 @@ export function PasswordInputElement(props: InputProps): JSX.Element {
) : (
<FormattedMessage defaultMessage="SHOW" description="nin/password button label" />
)}
</button>
</EduIDButton>
</div>
);
}
6 changes: 2 additions & 4 deletions src/styles/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,8 @@ button.btn-icon {
}
}

// login username-pw / reset-password set-new-password
.show-hide-button {
@extend #{".btn", ".btn-link", ".btn-sm"};

//textual toggle control, eg. copy/show
.txt-toggle-btn {
position: absolute;
right: 1rem;
}
Expand Down
8 changes: 8 additions & 0 deletions src/translation/extractedMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,10 @@
"developer_comment": "eidas proofing help text",
"string": "To use this option you will need to first create a digital ID-card in the {freja_eid_link} app."
},
"YhOtY3": {
"developer_comment": "copied button label",
"string": "COPIED"
},
"Z4yZ3N": {
"developer_comment": "Use another device, finished",
"string": "After using the code on the other device, please close this browser window."
Expand Down Expand Up @@ -1990,6 +1994,10 @@
"developer_comment": "Account recovery cancel information",
"string": "If you decide to cancel, simply click the Go Back button to return to the login page."
},
"kKMiD/": {
"developer_comment": "copy button label",
"string": "COPY"
},
"kN1GC+": {
"developer_comment": "Make primary button",
"string": "make primary"
Expand Down

0 comments on commit 1da1b95

Please sign in to comment.