Omar Ahmed Hassan b4451da2f4
Fix displayed identical fonts in sign PDF (#2751)
# Description of Changes

### Changes:
- Add a new custom select to display fonts correctly and to allow more
styling flexibility in Sign PDF feature by hiding the original
`<select>` element (`display: none;`) and wrap it with a `<div>` and
then create a custom selection menu using `<div>`s and CSS to achieve
the required results due to the limitations of `<select>` and `<option>`
while still preserving the hidden `<select>` for form submission.

### Why was the change made?
1. A bug that caused font families to not be displayed in Firefox.
2. Select/Option element are not flexible when it comes to styling
(compared to DIVs for example) but bullet point `1.` is of higher
priority.

### UI Changes:
- Dark Mode:
   - Before:

![image](https://github.com/user-attachments/assets/37f79c81-8155-4430-9e36-2b4cc2a442e6)

   - After:

![image](https://github.com/user-attachments/assets/e6a2b209-0d8f-4ff2-94ea-54827706d0cd)

- Light Mode:
   - Before:

![image](https://github.com/user-attachments/assets/c5356899-6be9-497b-8ad9-d50e6bd077d5)

   - After: 

![image](https://github.com/user-attachments/assets/29373b1a-cfa1-48a2-9040-3ed2fd5f7fd3)

Note:
- Changes in `sign.js` are between the lines 95-228, as it seems the
file was auto-formatted affecting whitespaces and
single_quotes/double_quotes.


#### Useful quotes from MDN:

> [Styling with
CSS](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option#styling_with_css)
Styling the <option> element is highly limited. Options don't inherit
the font set on the parent. In Firefox, only
[color](https://developer.mozilla.org/en-US/docs/Web/CSS/color) and
[background-color](https://developer.mozilla.org/en-US/docs/Web/CSS/background-color)
can be set, however in Chrome and Safari it's not possible to set any
properties. You can find more details about styling in [our guide to
advanced form
styling](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Advanced_form_styling).

#### Useful references:
- [Option
Element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option#styling_with_css)
- [Select
Element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select)
- [Advanced Form
Styling](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Advanced_form_styling)

Closes #1575

---

## Checklist

### General

- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [x] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md)
(if applicable)
- [x] I have performed a self-review of my own code
- [x] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### UI Changes (if applicable)

- [x] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [x] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing)
for more details.
2025-01-20 12:11:31 +00:00

238 lines
4.2 KiB
CSS

select#font-select,
select#font-select option {
height: 60px;
/* Adjust as needed */
font-size: 30px;
/* Adjust as needed */
}
.drawing-pad-container {
text-align: center;
}
#drawing-pad-canvas {
background: rgba(125, 125, 125, 0.2);
width: 100%;
height: 300px;
}
#box-drag-container {
position: relative;
margin: 20px 0;
}
.draggable-buttons-box {
position: relative;
top: 0;
padding: 10px;
width: calc(100% + 4.4rem);
display: flex;
gap: 5px;
z-index: 5;
margin-left: -2.2rem;
}
.draggable-buttons-box > button {
z-index: 4;
background-color: rgba(13, 110, 253, 0.1);
flex: 1 1 auto;
min-width: 2.5rem;
max-width: 4rem;
}
.rotation-handle {
width: 20px;
height: 20px;
border: 2px solid #3498db;
background-color: rgba(52, 152, 219, 0.1);
color: white;
border-radius: 50%;
text-align: center;
line-height: 20px;
position: absolute;
cursor: grab;
top: -30px;
left: calc(50% - 10px);
}
.draggable-canvas {
border: 2px solid #3498db;
position: absolute;
touch-action: none;
user-select: none;
top: 0px;
left: 0;
z-index: 100;
cursor: grab;
transition: transform 0.1s ease-out;
background-color: rgba(52, 152, 219, 0.1);
/* Light blue background */
}
.draggable-canvas:active {
cursor: grabbing;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
/* Shadow on active drag */
}
.draggable-canvas:hover {
border: 2px solid #2980b9;
/* Darker border on hover */
background-color: rgba(52, 152, 219, 0.2);
/* Darken background on hover */
}
.signature-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 1rem;
padding: 1rem;
max-height: 400px;
overflow-y: auto;
}
.signature-list {
max-height: 400px;
overflow-y: auto;
}
.signature-list-item {
padding: 0.75rem;
border: 1px solid #dee2e6;
border-radius: 4px;
margin-bottom: 0.5rem;
cursor: pointer;
transition: background-color 0.2s;
}
.signature-list-item:hover {
background-color: #f8f9fa;
}
.signature-list-info {
display: flex;
justify-content: space-between;
align-items: center;
}
.signature-list-name {
font-weight: 500;
}
.signature-list-details {
color: #6c757d;
font-size: 0.875rem;
}
.signature-list-details small:not(:last-child) {
margin-right: 1rem;
}
.view-toggle {
text-align: right;
padding: 0.5rem 1rem;
}
.input-with-icon {
position: relative;
display: inline-flex;
align-items: center;
}
.input-with-icon .icon {
position: absolute;
left: 0.5rem;
pointer-events: none;
color: #aaa;
}
.input-with-icon input {
padding-left: 2.2rem;
}
.small-file-container-saved {
padding-top: 1px;
position: relative;
row-gap: 1px;
height: 60px;
width: 60px;
top: 4px;
}
.small-file-container-saved:hover .drag-icon {
display: flex;
}
/* The container must be positioned relative: */
.custom-select {
position: relative;
font-family: inherit;
}
.custom-select select {
display: none; /*hide original SELECT element: */
}
.select-selected {
background-color: inherit;
line-height: 30px;
font-size: 30px;
border-radius: 3rem !important;
}
/* Style the arrow inside the select element: */
.select-selected:after {
position: absolute;
content: "";
top: 50%;
right: 10px;
translate: 0 -50%;
width: 0;
height: 0;
border: 6px solid transparent;
border-color: #fff transparent transparent transparent;
}
/* Point the arrow upwards when the select box is open (active): */
.select-selected.select-arrow-active:after {
border-color: transparent transparent #fff transparent;
translate: 0 -75%;
}
/* style the items (options), including the selected item: */
.select-items div,
.select-selected {
color: inherit;
padding: 8px 16px;
cursor: pointer;
}
.select-items div {
border: 1px solid transparent;
border-color: transparent transparent transparent transparent;
line-height: 30px;
font-size: 30px;
}
/* Style items (options): */
.select-items {
position: absolute;
background-color: inherit;
top: 100%;
left: 0;
right: 0;
z-index: 101;
border: inherit;
}
/* Hide the items when the select box is closed: */
.select-hide {
display: none;
}
.select-items div:hover,
.same-as-selected {
background-color: rgba(54, 54, 54, 0.1);
}