mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-10-30 07:14:33 +00:00
support App envs obscured input text (#516)
* support App envs obscured input text * wip
This commit is contained in:
1 parent
46727f621b
commit
020b11e8ef
4 files changed
+147
-31
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import React, { useState } from "react";
|
||||
import { Icons } from "src/components/icons";
|
||||
import "./styles.scss";
|
||||
|
||||
interface ObscureInputProps
|
||||
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> {
|
||||
value: string;
|
||||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
||||
}
|
||||
|
||||
export const ObscureInput = ({
|
||||
value,
|
||||
onChange,
|
||||
className = "",
|
||||
...props
|
||||
}: ObscureInputProps) => {
|
||||
const [revealed, setRevealed] = useState(false);
|
||||
|
||||
return (
|
||||
<div className="passwd">
|
||||
<input
|
||||
type={revealed ? "text" : "password"}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
className={className}
|
||||
{...props}
|
||||
/>
|
||||
<button
|
||||
className="btnty"
|
||||
type="button"
|
||||
onClick={() => setRevealed(!revealed)}
|
||||
aria-label={revealed ? "Hide text" : "Show text"}
|
||||
>
|
||||
{revealed ? <Icons.EyeOff /> : <Icons.Eye />}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ObscureInput;
|
||||
@@ -0,0 +1,39 @@
|
||||
@use "src/styles/vars";
|
||||
@use "@jambonz/ui-kit/src/styles/vars" as ui-vars;
|
||||
@use "@jambonz/ui-kit/src/styles/mixins" as ui-mixins;
|
||||
|
||||
.obscure-input {
|
||||
position: relative; // This is correct
|
||||
width: 100%;
|
||||
display: block; // Add this to ensure proper containing block
|
||||
|
||||
&__field {
|
||||
width: 100%;
|
||||
padding-right: 40px;
|
||||
font-family: ui-vars.$font-mono;
|
||||
box-sizing: border-box; // Add this to ensure padding doesn't expand width
|
||||
}
|
||||
|
||||
&__toggle {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 0;
|
||||
height: 100%; // Make the button take full height of input
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 2; // Ensure button is above input
|
||||
|
||||
svg {
|
||||
stroke: ui-vars.$jambonz;
|
||||
pointer-events: none;
|
||||
width: 18px; // Control icon size
|
||||
height: 18px;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user