-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Migrate attachments to CSS modules #5491
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
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| :global(.webchat) .component-icon { | ||
| min-width: var(--webchat__component-icon--size, 1em); | ||
| min-height: var(--webchat__component-icon--size, 1em); | ||
| place-self: center; | ||
|
|
||
| /* Use the image as texture. */ | ||
| background-image: var(--webchat__component-icon--image, none); | ||
| background-position: center; | ||
| background-repeat: no-repeat; | ||
| background-size: var(--webchat__component-icon--size, 1em); | ||
|
|
||
| /* If image is not set, fallback to solid color. */ | ||
| background-color: var(--webchat__component-icon--color, transparent); | ||
|
|
||
| /* 3. Set the mask if any. */ | ||
| -webkit-mask-image: var(--webchat__component-icon--mask); | ||
| -webkit-mask-position: center; | ||
| -webkit-mask-repeat: no-repeat; | ||
| -webkit-mask-size: var(--webchat__component-icon--size, 1em); | ||
| mask-image: var(--webchat__component-icon--mask); | ||
| mask-position: center; | ||
| mask-repeat: no-repeat; | ||
| mask-size: var(--webchat__component-icon--size, 1em); | ||
| } | ||
|
|
||
| /* #region: Appearance */ | ||
| :global(.webchat) .appearance--text { | ||
| --webchat__component-icon--color: currentColor; | ||
| } | ||
| /* #endregion */ | ||
|
|
||
| /* #region: Icons */ | ||
| :global(.webchat) .icon--dismiss { | ||
| --webchat__component-icon--mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m4.09 4.22.06-.07a.5.5 0 0 1 .63-.06l.07.06L10 9.29l5.15-5.14a.5.5 0 0 1 .63-.06l.07.06c.18.17.2.44.06.63l-.06.07L10.71 10l5.14 5.15c.18.17.2.44.06.63l-.06.07a.5.5 0 0 1-.63.06l-.07-.06L10 10.71l-5.15 5.14a.5.5 0 0 1-.63.06l-.07-.06a.5.5 0 0 1-.06-.63l.06-.07L9.29 10 4.15 4.85a.5.5 0 0 1-.06-.63l.06-.07-.06.07Z"/></svg>'); | ||
| } | ||
| /* #endregion */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { validateProps } from 'botframework-webchat-react-valibot'; | ||
| import { useStyles } from 'botframework-webchat-styles/react'; | ||
| import cx from 'classnames'; | ||
| import React, { memo } from 'react'; | ||
| import { object, optional, pipe, readonly, string, type InferInput } from 'valibot'; | ||
|
|
||
| import createIconComponent from '../Utils/createIconComponent'; | ||
| import styles from './ComponentIcon.module.css'; | ||
|
|
||
| const componentIconPropsSchema = pipe( | ||
| object({ | ||
| appearance: optional(string()), | ||
| className: optional(string()), | ||
| icon: optional(string()), | ||
| size: optional(string()) | ||
| }), | ||
| readonly() | ||
| ); | ||
|
|
||
| type ComponentIconProps = InferInput<typeof componentIconPropsSchema>; | ||
|
|
||
| function BaseComponentIcon(props: ComponentIconProps) { | ||
| const { className } = validateProps(componentIconPropsSchema, props); | ||
|
|
||
| const classNames = useStyles(styles); | ||
|
|
||
| return <div className={cx(classNames['component-icon'], className)} />; | ||
| } | ||
|
|
||
| const ComponentIcon = createIconComponent(styles, BaseComponentIcon); | ||
|
|
||
| ComponentIcon.displayName = 'ComponentIcon'; | ||
|
|
||
| export default memo(ComponentIcon); | ||
| export { componentIconPropsSchema, type ComponentIconProps }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default as ComponentIcon } from './ComponentIcon'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
packages/component/src/SendBox/AttachmentBar/AttachmentBar.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| :global(.webchat) .send-box-attachment-bar { | ||
| grid-area: attachment-bar; | ||
|
|
||
| &.send-box-attachment-bar--as-list-item { | ||
| max-height: var(--webchat__max-height--send-box-attachment-bar); | ||
| overflow-y: auto; | ||
| scrollbar-gutter: stable; | ||
| scrollbar-width: thin; | ||
| } | ||
|
|
||
| &.send-box-attachment-bar--as-thumbnail { | ||
| overflow-x: auto; | ||
| } | ||
|
|
||
| .send-box-attachment-bar__box { | ||
| gap: 4px; | ||
| } | ||
|
|
||
| &.send-box-attachment-bar--as-list-item .send-box-attachment-bar--box { | ||
|
OEvgeny marked this conversation as resolved.
Outdated
|
||
| display: grid; | ||
| grid-template-columns: 1fr 1fr; | ||
|
|
||
| &:not(:empty) { | ||
| padding: 4px; | ||
| } | ||
| } | ||
|
|
||
| &.send-box-attachment-bar--as-thumbnail .send-box-attachment-bar--box { | ||
|
OEvgeny marked this conversation as resolved.
Outdated
|
||
| display: flex; | ||
| scrollbar-width: thin; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
packages/component/src/SendBox/AttachmentBar/AttachmentBarItem.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| /* #region List item */ | ||
| :global(.webchat) .send-box-attachment-bar-item { | ||
| display: grid; | ||
| flex-shrink: 0; | ||
| grid-template-rows: auto; | ||
| font-family: var(--webchat__font--primary); | ||
|
|
||
| &.send-box-attachment-bar-item--as-list-item { | ||
| border-radius: 4px; | ||
| box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.14), 0px 0px 2px rgba(0, 0, 0, 0.12); | ||
| grid-template-areas: 'body auxiliary'; | ||
| grid-template-columns: 1fr auto; | ||
| padding: 2px; | ||
| } | ||
|
|
||
| &.send-box-attachment-bar-item--as-thumbnail { | ||
| aspect-ratio: 1 / 1; | ||
| border: solid 1px rgba(0, 0, 0, 0.25); /* Figma has border-width of 0.96px. */ | ||
| border-radius: 8px; /* Figma is 7.68px. */ | ||
| grid-template-areas: 'body'; | ||
| grid-template-columns: auto; | ||
| height: 80px; /* <= 87px would fit white-label design with 3 thumbnails. */ | ||
| overflow: hidden; | ||
| } | ||
| } | ||
| /* #endregion */ | ||
|
|
||
| /* #region Delete button */ | ||
| :global(.webchat) .send-box-attachment-bar-item__delete-button { | ||
| /* https://react.fluentui.dev/?path=/docs/theme-colors--docs */ | ||
| appearance: none; | ||
| align-items: center; | ||
| background-color: White; /* Background/colorNeutralBackground1 */ | ||
| border-color: #d1d1d1; /* Stroke/colorNeutralStroke1 */ | ||
| border-radius: 4px; /* BorderRadiusXS is not defined in Fluent UI, guessing it is 4px. */ | ||
| cursor: pointer; | ||
| grid-area: body; | ||
| justify-self: end; | ||
| opacity: 1; | ||
| padding: 0; | ||
| transition: opacity 50ms; /* Assume ultra-fast. */ | ||
| color: #242424; /* Background/colorNeutralForeground1 */ | ||
| --webchat__component-icon--size: 19px; | ||
|
|
||
| &:hover { | ||
| background-color: #f5f5f5; /* Background/colorNeutralBackground1Hover */ | ||
| border-color: #c7c7c7; /* Stroke/colorNeutralStroke1Hover */ | ||
| } | ||
|
|
||
| &:active { | ||
| background-color: #e0e0e0; /* Background/colorNeutralBackground1Pressed */ | ||
| border-color: #c7c7c7; /* Stroke/colorNeutralStroke1Pressed */ | ||
| } | ||
|
|
||
| &:disabled, | ||
| &[aria-disabled='true'] { | ||
| background-color: #f0f0f0; /* Background/colorNeutralBackgroundDisabled */ | ||
| border-color: #e0e0e0; /* Stroke/colorNeutralStrokeDisabled */ | ||
| color: #bdbdbd; /* Stroke/colorNeutralForegroundDisabled */ | ||
| } | ||
| } | ||
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| :global(.webchat.theme--prefers-color-scheme) .send-box-attachment-bar-item__delete-button { | ||
| background-color: #292929; /* Background/colorNeutralBackground1 */ | ||
| border-color: #666666; /* Stroke/colorNeutralStroke1 */ | ||
| color: #ffffff; /* Background/colorNeutralBackground1 */ | ||
|
|
||
| &:hover { | ||
| background-color: #3d3d3d; /* Background/colorNeutralBackground1Hover */ | ||
| border-color: #757575; /* Stroke/colorNeutralStroke1Hover */ | ||
| } | ||
|
|
||
| &:active { | ||
| background-color: #1f1f1f; /* Background/colorNeutralBackground1Pressed */ | ||
| border-color: #6b6b6b; /* Stroke/colorNeutralStroke1Pressed */ | ||
| } | ||
|
|
||
| &:disabled, | ||
| &[aria-disabled='true'] { | ||
| background-color: #141414; /* Background/colorNeutralBackgroundDisabled */ | ||
| border-color: #424242; /* Stroke/colorNeutralStrokeDisabled */ | ||
| color: #5c5c5c; /* Stroke/colorNeutralForegroundDisabled */ | ||
| } | ||
| } | ||
| } | ||
|
|
||
| :global(.webchat) | ||
| .send-box-attachment-bar-item.send-box-attachment-bar-item--as-list-item | ||
| .send-box-attachment-bar-item__delete-button { | ||
| border: 0; | ||
| grid-area: auxiliary; | ||
| height: 24px; | ||
| width: 24px; | ||
|
|
||
| .send-box-attachment-bar-item__dismiss-icon { | ||
| --webchat__component-icon--size: 7px; | ||
| --webchat__component-icon--mask: url('data:image/svg+xml;utf8,<svg viewBox="0 0 8 8" xmlns="http://www.w3.org/2000/svg"><path d="M0.0885911 0.215694L0.146447 0.146447C0.320013 -0.0271197 0.589437 -0.046405 0.784306 0.0885911L0.853553 0.146447L4 3.293L7.14645 0.146447C7.34171 -0.0488154 7.65829 -0.0488154 7.85355 0.146447C8.04882 0.341709 8.04882 0.658291 7.85355 0.853553L4.707 4L7.85355 7.14645C8.02712 7.32001 8.0464 7.58944 7.91141 7.78431L7.85355 7.85355C7.67999 8.02712 7.41056 8.0464 7.21569 7.91141L7.14645 7.85355L4 4.707L0.853553 7.85355C0.658291 8.04882 0.341709 8.04882 0.146447 7.85355C-0.0488154 7.65829 -0.0488154 7.34171 0.146447 7.14645L3.293 4L0.146447 0.853553C-0.0271197 0.679987 -0.046405 0.410563 0.0885911 0.215694L0.146447 0.146447L0.0885911 0.215694Z"/></svg>'); | ||
| } | ||
| } | ||
|
|
||
| :global(.webchat) | ||
| .send-box-attachment-bar-item.send-box-attachment-bar-item--as-thumbnail | ||
| .send-box-attachment-bar-item__delete-button { | ||
| border-style: solid; /* Border color will be set elsewhere. */ | ||
| border-width: 1px; /* Figma has border-width of 0.96px. */ | ||
| grid-area: body; /* This was already set, but keeping for explicitness from original */ | ||
| height: 23px; /* Figma is 23.04px. */ | ||
| margin: 8px; /* Figma is 7.68px. */ | ||
| width: 23px; /* Figma is 23.04px. */ | ||
| } | ||
|
|
||
| @media not (prefers-reduced-motion: reduce) { | ||
| :global(.webchat) | ||
| .send-box-attachment-bar-item.send-box-attachment-bar-item--as-thumbnail:not(:hover):not(:focus-within) | ||
| .send-box-attachment-bar-item__delete-button { | ||
| opacity: 0; | ||
| } | ||
| } | ||
| /* #endregion */ | ||
|
|
||
| /* #region Preview */ | ||
| :global(.webchat) .send-box-attachment-bar-item__preview { | ||
| align-items: center; | ||
| display: grid; | ||
| grid-area: body; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| :global(.webchat) | ||
| .send-box-attachment-bar-item.send-box-attachment-bar-item--as-list-item | ||
| .send-box-attachment-bar-item__preview { | ||
| padding-inline: 8px; | ||
| } | ||
| /* #endregion */ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.