-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #454 from acelaya-forks/feature/qr-code-defaults
Make QR codes start with default options from server
- Loading branch information
Showing
14 changed files
with
268 additions
and
122 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
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,65 @@ | ||
import { faArrowRotateLeft } from '@fortawesome/free-solid-svg-icons'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import type { FC } from 'react'; | ||
import { useId } from 'react'; | ||
import { Button, FormGroup } from 'reactstrap'; | ||
|
||
export type QrCodeDimensionControlProps = { | ||
name: string; | ||
value?: number; | ||
step?: number; | ||
min?: number; | ||
max?: number; | ||
initial?: number; | ||
onChange: (newValue?: number) => void; | ||
className?: string; | ||
}; | ||
|
||
export const QrDimensionControl: FC<QrCodeDimensionControlProps> = ( | ||
{ name, value, step, min, max, onChange, className, initial = min }, | ||
) => { | ||
const id = useId(); | ||
|
||
return ( | ||
<FormGroup className={className}> | ||
{value === undefined && ( | ||
<Button | ||
outline | ||
color="link" | ||
className="text-start fst-italic w-100" | ||
style={{ color: 'var(--input-text-color)', borderColor: 'var(--border-color)' }} | ||
onClick={() => onChange(initial)} | ||
> | ||
Customize {name} | ||
</Button> | ||
)} | ||
{value !== undefined && ( | ||
<div className="d-flex gap-3"> | ||
<div className="d-flex flex-column flex-grow-1"> | ||
<label htmlFor={id} className="text-capitalize">{name}: {value}px</label> | ||
<input | ||
id={id} | ||
type="range" | ||
className="form-control-range" | ||
value={value} | ||
step={step} | ||
min={min} | ||
max={max} | ||
onChange={(e) => onChange(Number(e.target.value))} | ||
/> | ||
</div> | ||
<Button | ||
aria-label={`Default ${name}`} | ||
title={`Default ${name}`} | ||
outline | ||
color="link" | ||
onClick={() => onChange(undefined)} | ||
style={{ color: 'var(--input-text-color)', borderColor: 'var(--border-color)' }} | ||
> | ||
<FontAwesomeIcon icon={faArrowRotateLeft} /> | ||
</Button> | ||
</div> | ||
)} | ||
</FormGroup> | ||
); | ||
}; |
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
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
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
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
Oops, something went wrong.