Skip to content

New: Allow setting custom label style #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,20 @@ properties:
# This option makes it possible hide the whole editor (incl. label) based on data source
hidden: false

# Only in view 'grid', 'flex' and 'flex-start': Set custom style for the labels
# The same is allowed inside a single value
labelCustomStyle:
fontSize: 25
lineHeight: "39px"

# Set the values
values:
left:
# Only in view 'grid', 'flex' and 'flex-start': Set custom style for the label
labelCustomStyle:
fontSize: 25
lineHeight: "39px"

# Show a label
label: "Left"
# Label on active state
Expand Down
9 changes: 8 additions & 1 deletion Resources/Private/Editor/ToggleEditor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const defaultOptions = {
hidden: false,
dataSourceIdentifier: null,
dataSourceUri: null,
labelCustomStyle: null,
};

function Editor(props) {
Expand All @@ -48,6 +49,7 @@ function Editor(props) {
dataSourceUri,
dataSourceAdditionalData,
multiple,
labelCustomStyle,
} = mergedOptions;
const allowEmpty = multiple || mergedOptions.allowEmpty;
const { value, commit, highlight, i18nRegistry, id, dataSourcesDataLoader, renderHelpIcon } = props;
Expand Down Expand Up @@ -338,7 +340,10 @@ function Editor(props) {
<Icons item={item} isCurrent={isCurrent} size={iconSize} />
<PreviewImage item={item} isCurrent={isCurrent} />
{label && (
<span className={clsx(item.icon || item.preview ? style.label : null)}>
<span
className={clsx(item.icon || item.preview ? style.label : null)}
style={item.labelCustomStyle || labelCustomStyle || {}}
>
{label}
</span>
)}
Expand All @@ -363,9 +368,11 @@ Editor.propTypes = {
emptyValue: PropTypes.string,
multiple: PropTypes.bool,
iconSize: PropTypes.oneOf(["xs", "sm", "lg", "2x", "3x"]),
labelCustomStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
values: PropTypes.objectOf(
PropTypes.shape({
label: PropTypes.string,
labelCustomStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
icon: PropTypes.string,
iconRotate: PropTypes.number,
description: PropTypes.string,
Expand Down
4 changes: 2 additions & 2 deletions Resources/Public/Plugin.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Resources/Public/Plugin.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "Carbon.DirectionEditor",
"license": "proprietary",
"private": true,
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0",
"packageManager": "pnpm@10.2.0+sha512.0d27364e0139c6aadeed65ada153135e0ca96c8da42123bd50047f961339dc7a758fc2e944b428f52be570d1bd3372455c1c65fa2e7aa0bfbf931190f9552001",
"scripts": {
"build": "node build.mjs --production",
"watch": "node build.mjs --watch",
Expand Down