Skip to content

Commit

Permalink
refactor(ui): Improve StringInput component styling and label handlin…
Browse files Browse the repository at this point in the history
…g; update tooltip in app.py
  • Loading branch information
Lasse-numerous committed Dec 23, 2024
1 parent 0b9df43 commit 2166241
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
4 changes: 1 addition & 3 deletions js/src/components/ui/String.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ export function StringInput({
return (
<div className={`string-input-container ${fitToContent ? 'fit-to-content' : ''}`}>
<div className="input-wrapper" style={{ width: fitToContent ? 'auto' : '100%' }}>
<div className="string-label-container" style={{ alignItems: 'center' }}>
<label className="string-label">
<span >{uiLabel}</span>
<span className="string-label-text">{uiLabel}</span>
{uiTooltip && <Tooltip tooltip={uiTooltip} />}
</label>
</div>
<input
type={isPassword ? "password" : "text"}
value={value}
Expand Down
28 changes: 20 additions & 8 deletions js/src/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ main {

label {
display: block;
margin-bottom: 0.5rem;
margin-bottom: 0rem;
font-weight: 500;
color: #444;
}
Expand Down Expand Up @@ -1396,15 +1396,22 @@ select::-ms-expand {
z-index: 9999 !important;
}

.string-label-text {
width: fit-content;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.string-input-container {
position: relative;
display: flex;
flex-direction: column;
width: 100%;
vertical-align: top;
gap: 4px;
}


.string-input-container.fit-to-content {
width: fit-content;
display: inline-flex;
Expand All @@ -1417,17 +1424,14 @@ select::-ms-expand {
color: var(--ui-widget-primary-text);
font-size: 14px;
padding-left: 8px;
margin-right: 8px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
position: relative;
z-index: 1;
margin-bottom: 0;
}


.input-wrapper {
position: relative;
z-index: 0;
gap: 4px;
}

input[type="text"] {
Expand Down Expand Up @@ -2218,4 +2222,12 @@ input[type="text"].invalid:focus {

.modal-button.secondary:hover {
background-color: var(--ui-widget-hover-background);
}

.string-label-container {
display: flex;
align-items: center;
height: 100%;
margin-top: 0;
margin-bottom: 0;
}
2 changes: 1 addition & 1 deletion python/examples/marimo/numerous/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _(mo):

@app.cell
def _(aw, value, wi):
counter = aw(wi.Number(default=value(), label="Counter:", fit_to_content=True))
counter = aw(wi.Number(default=value(), label="Counter:", fit_to_content=True, tooltip="This is the value the counter has reached."))
return (counter,)


Expand Down

0 comments on commit 2166241

Please sign in to comment.