diff --git a/packages/ibm-products-styles/src/components/ConditionBuilder/_condition-builder.scss b/packages/ibm-products-styles/src/components/ConditionBuilder/_condition-builder.scss index 860f4380e5..63c21c183e 100644 --- a/packages/ibm-products-styles/src/components/ConditionBuilder/_condition-builder.scss +++ b/packages/ibm-products-styles/src/components/ConditionBuilder/_condition-builder.scss @@ -8,7 +8,11 @@ // Standard imports. @use '../../global/styles/project-settings' as c4p-settings; @use '../../global/styles/mixins'; +@use '@carbon/react/scss/spacing' as *; +@use '@carbon/react/scss/type' as *; +@use '@carbon/react/scss/theme'; +@use './styles/index'; // Other Carbon settings if needed // TODO: @use '@carbon/styles/scss/grid'; // or @@ -23,3 +27,22 @@ $block-class: #{c4p-settings.$pkg-prefix}--condition-builder; // .#{$block-class} { // // TODO: Styles. // } + +.#{$block-class}__condition-builder__group { + display: flex; +} + +.#{$block-class}__condition-wrapper { + display: flex; + flex-flow: row wrap; +} +.#{$block-class}__gap { + margin-right: $spacing-01; +} +.#{$block-class}__gap-bottom { + margin-bottom: $spacing-01; +} +.#{$block-class}__condition-block { + display: flex; + flex-direction: row; +} diff --git a/packages/ibm-products-styles/src/components/ConditionBuilder/styles/_conditionBuilderCondition.scss b/packages/ibm-products-styles/src/components/ConditionBuilder/styles/_conditionBuilderCondition.scss new file mode 100644 index 0000000000..3c9ec15437 --- /dev/null +++ b/packages/ibm-products-styles/src/components/ConditionBuilder/styles/_conditionBuilderCondition.scss @@ -0,0 +1,47 @@ +@use '@carbon/react/scss/spacing' as *; +@use '@carbon/react/scss/motion'; +@use '@carbon/styles/scss/components/tag' as *; +@use '@carbon/styles/scss/utilities/focus-outline'; +@use '../../../global/styles/project-settings' as c4p-settings; +@use '@carbon/styles/scss/type'; +@use '@carbon/styles/scss/type' as *; + +$block-class: #{c4p-settings.$pkg-prefix}--condition-builder; + +.#{$block-class}__condition-block { + position: relative; + display: inline-flex; + margin-block-end: $spacing-01; +} + +.#{$block-class}__condition-block:focus { + outline: none; +} + +.#{$block-class}__condition-builder-condition:focus::after, +.#{$block-class}__condition-block:focus::after { + @include focus-outline.focus-outline('outline'); + + position: absolute; + content: ''; + inset: 0; +} + +.#{$block-class}__condition-builder-condition__deletion-preview + .#{$block-class}__condition-builder-button { + background-color: $tag-background-red; + color: $tag-color-red; +} + +.#{$block-class}__condition-builder-condition__deletion-preview + .#{$block-class}__condition-builder-button:hover { + background-color: $tag-hover-red; +} + +.#{$block-class}__text-ellipsis { + display: block; + overflow: hidden; + max-width: $spacing-13; + text-overflow: ellipsis; + text-wrap: nowrap; +} diff --git a/packages/ibm-products-styles/src/components/ConditionBuilder/styles/_conditionBuilderItem.scss b/packages/ibm-products-styles/src/components/ConditionBuilder/styles/_conditionBuilderItem.scss new file mode 100644 index 0000000000..f54b1d410c --- /dev/null +++ b/packages/ibm-products-styles/src/components/ConditionBuilder/styles/_conditionBuilderItem.scss @@ -0,0 +1,161 @@ +@use '@carbon/react/scss/theme' as *; +@use '../../../global/styles/project-settings' as c4p-settings; +@use '@carbon/react/scss/spacing' as *; +@use '@carbon/react/scss/utilities' as *; +@use '@carbon/react/scss/motion' as *; +@use '@carbon/react/scss/utilities/focus-outline'; +@use '@carbon/styles/scss/components/tag'; + +@use '@carbon/styles/scss/type' as *; + +$block-class: #{c4p-settings.$pkg-prefix}--condition-builder; + +.#{$block-class}__content-container * { + @include type-style('body-01'); +} + +.#{$block-class}__condition-builder-item__content { + overflow: auto; + min-width: $spacing-07 + $spacing-13; + max-width: $spacing-13 + $spacing-13; + max-height: $spacing-13 + $spacing-13 + $spacing-07; +} + +.#{$block-class}__condition-builder-item__title { + @include type-style('heading-01'); + + padding: $spacing-05; +} + +.#{$block-class}__condition-builder-item-option__search { + padding-block-end: $spacing-05; + padding-inline: $spacing-05; +} + +.#{$block-class}__condition-builder-item-option__option { + height: 2rem; + cursor: pointer; + padding-inline: $spacing-05; +} + +.#{$block-class}__condition-builder-item-option__option:hover { + background-color: $layer-hover; +} + +.#{$block-class}__condition-builder-item-option__option-content { + display: flex; + height: 100%; + align-items: center; +} + +.#{$block-class}__condition-builder-item-option__option-label { + display: flex; + overflow: hidden; + align-items: center; + column-gap: $spacing-03; + text-overflow: ellipsis; + white-space: nowrap; +} + +.#{$block-class}__condition-builder-item-option + > ul[aria-multiSelectable='true'] + .#{$block-class}__condition-builder-item-option__option-label { + justify-content: center; +} + +.#{$block-class}__condition-builder-item-option__option:not(:first-of-type) + .#{$block-class}__condition-builder-item-option__option-content { + border-block-start: 0.0625rem solid $border-subtle; +} + +.#{$block-class}__condition-builder-item-option__option:hover + .#{$block-class}__condition-builder-item-option__option-content, +.#{$block-class}__condition-builder-item-option__option[aria-selected='true'] + .#{$block-class}__condition-builder-item-option__option-content, +.#{$block-class}__condition-builder-item-option__option:hover + + .#{$block-class}__condition-builder-item-option__option + .#{$block-class}__condition-builder-item-option__option-content, +.#{$block-class}__condition-builder-item-option__option[aria-selected='true'] + + .#{$block-class}__condition-builder-item-option__option + .#{$block-class}__condition-builder-item-option__option-content { + border-block-start-color: transparent; +} + +.#{$block-class}__condition-builder-item-option__option[aria-selected='true'] { + background-color: $layer-selected; +} + +.#{$block-class}__condition-builder-item-option__option[aria-selected='true']:hover { + background-color: $layer-selected-hover; +} + +.#{$block-class}__condition-builder-item-date, +.#{$block-class}__condition-builder-item-text, +.#{$block-class}__condition-builder-item-number { + padding-block-end: $spacing-05; + padding-inline: $spacing-05; +} + +.#{$block-class}__condition-builder-checkmark { + margin-left: auto; +} + +.#{$block-class}__condition-builder-button { + @include button-reset(); + + display: inline-flex; + height: $spacing-07; + align-items: center; + background-color: $layer; + color: inherit; + column-gap: $spacing-02; + cursor: pointer; + padding-inline: $spacing-02; + white-space: nowrap; +} +.#{$block-class}__condition-builder-button:hover { + background-color: $layer-hover; +} +.#{$block-class}__condition-builder__group.hoveredConnector + .#{$block-class}__condition-wrapper + > .conditionBlockWrapper + .#{$block-class}__connector-button { + background-color: $layer-hover; +} + +.#{$block-class}__condition-builder-button:focus { + @include focus-outline.focus-outline('outline'); + + content: ''; + inset: 0; +} + +.#{$block-class}__statement-button, +.#{$block-class}__connector-button { + min-width: $spacing-10; + padding-inline: $spacing-03; +} +.#{$block-class}__property-field { + @include type-style('heading-01'); + + padding-left: $spacing-03; +} +.#{$block-class}__close-condition { + padding-right: $spacing-03; +} +.#{$block-class}__add-button { + padding-right: $spacing-03; + padding-left: $spacing-03; +} +.#{$block-class}__conditionWrapper { + display: flex; +} + +.#{$block-class}__multiselectSelectionStatusContainer { + display: flex; + padding-inline: $spacing-05; +} + +.#{$block-class}__condition-builder-item-option__option:focus { + @include focus-outline.focus-outline('outline'); +} diff --git a/packages/ibm-products-styles/src/components/ConditionBuilder/styles/_index.scss b/packages/ibm-products-styles/src/components/ConditionBuilder/styles/_index.scss new file mode 100644 index 0000000000..ff2061bed5 --- /dev/null +++ b/packages/ibm-products-styles/src/components/ConditionBuilder/styles/_index.scss @@ -0,0 +1,2 @@ +@use './conditionBuilderItem'; +@use './conditionBuilderCondition'; diff --git a/packages/ibm-products/src/components/ConditionBuilder/ConditionBlock/ConditionBlock.js b/packages/ibm-products/src/components/ConditionBuilder/ConditionBlock/ConditionBlock.js new file mode 100644 index 0000000000..749fa4933b --- /dev/null +++ b/packages/ibm-products/src/components/ConditionBuilder/ConditionBlock/ConditionBlock.js @@ -0,0 +1,234 @@ +import React, { useContext, useState } from 'react'; +import { Close } from '@carbon/react/icons'; +import { ConditionBuilderItem } from '../ConditionBuilderItem/ConditionBuilderItem'; +import PropTypes from 'prop-types'; + +import cx from 'classnames'; +import ConditionConnector from '../ConditionConnector/ConditionConnector'; + +import { ConditionBuilderContext } from '../ConditionBuilderContext/DataTreeContext'; +import { ConditionBuilderButton } from '../ConditionBuilderButton/ConditionBuilderButton'; +import { blockClass, translateWithId } from '../ConditionBuilderContext/DataConfigs'; + +/** + * This component build each block of condition consisting of property, operator value and close button. + */ + +const ConditionBlock=(props)=> { + let { property, value, operator } = props.state; + let { + onRemove, + state, + conjunction, + onConnectorOperatorChange, + isStatement, + group, + } = props; + const { inputConfig } = useContext(ConditionBuilderContext); + + const [showDeletionPreview, setShowDeletionPreview] = useState(false); + + //filtering the current property to access its properties and config options + const { icon, type, label } = + inputConfig.properties?.filter( + (eachProperty) => + eachProperty.label?.toUpperCase() == property?.toUpperCase() + )[0] ?? {}; + + return ( +