Skip to content

Commit 43cd92a

Browse files
committed
add inline option to label
1 parent 7cc3edf commit 43cd92a

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1919
- implemented support for `disabled` state in code editor
2020
- implemented support for `intent` states in code editor
2121
- `Label` component
22-
- added `additionalElements` property to display elements at the end of the label
22+
- `additionalElements` property to display elements at the end of the label
23+
- `inline` property to display the label component as inline block
2324
- `<NodeContent />`
2425
- `resizeDirections` to specifiy the axis that can be used to resize the node
2526
- `resizeMaxDimensions` to add maximum values for resizing height/width

src/components/Label/Label.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement>
3939
* Add other elements to the end of the label content
4040
*/
4141
additionalElements?: React.ReactNode | React.ReactNode[];
42+
/** Force label to get displayed as inline block element. */
43+
inline?: boolean;
4244
}
4345

4446
export const Label = ({
@@ -52,6 +54,7 @@ export const Label = ({
5254
isLayoutForElement = "label",
5355
emphasis = "normal",
5456
additionalElements,
57+
inline,
5558
...otherLabelProps
5659
}: LabelProps) => {
5760
let htmlElementstring = isLayoutForElement;
@@ -85,6 +88,7 @@ export const Label = ({
8588
className:
8689
`${eccgui}-label ${eccgui}-label--${emphasis}` +
8790
(className ? " " + className : "") +
91+
(inline ? ` ${eccgui}-label--inline` : "") +
8892
(disabled ? ` ${eccgui}-label--disabled` : ""),
8993
...otherLabelProps,
9094
},

src/components/Label/label.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ $eccgui-color-label-info: rgba($eccgui-color-workspace-text, $eccgui-opacity-mut
88
font-size: $eccgui-size-typo-label;
99
line-height: $eccgui-size-typo-label-lineheight;
1010
color: $eccgui-color-label-text;
11-
vertical-align: middle;
1211

1312
.#{$eccgui}-typography__overflowtext--passdown > & {
1413
display: flex;
@@ -17,6 +16,11 @@ $eccgui-color-label-info: rgba($eccgui-color-workspace-text, $eccgui-opacity-mut
1716
}
1817
}
1918

19+
.#{$eccgui}-label--inline {
20+
display: inline-block;
21+
vertical-align: middle;
22+
}
23+
2024
.#{$eccgui}-label--disabled {
2125
opacity: $eccgui-opacity-disabled;
2226
}

0 commit comments

Comments
 (0)