discourse/app/assets/stylesheets/common/d-editor.scss
Jarek Radosz ac79c5efc6
UX: Tweak composer styling (#15117)
* Even margins
* Slightly more muted and unified borders, separators, and icons
* Editor and preview area have same height
2021-11-30 17:41:22 +01:00

350 lines
5.9 KiB
SCSS

.d-editor-container {
display: flex;
flex-grow: 1;
max-width: 100%;
}
.d-editor {
display: flex;
flex-grow: 1;
min-height: 0;
}
.d-editor-textarea-wrapper,
.d-editor-preview-wrapper {
flex: 1;
}
.d-editor-textarea-wrapper {
display: flex;
flex-direction: column;
background-color: var(--secondary);
position: relative;
border: 1px solid var(--primary-low);
textarea {
background: transparent;
}
&.in-focus {
@include default-focus;
textarea {
outline: 0;
}
}
&.disabled {
cursor: not-allowed;
.d-editor-button-bar {
opacity: 0.5;
pointer-events: none;
}
}
}
.d-editor-preview-wrapper {
max-width: 49%;
margin-left: 1%;
display: flex;
flex-direction: column;
}
.d-editor-preview-wrapper {
overflow: auto;
cursor: default;
-webkit-overflow-scrolling: touch;
}
.d-editor-input,
.d-editor-preview {
box-sizing: border-box;
flex: 1 1 100%;
width: 100%;
margin: 0;
min-height: auto;
word-wrap: break-word;
-webkit-appearance: none;
border-radius: 0;
}
.d-editor-input {
border: 0;
padding: 10px;
height: 100%;
overflow-x: hidden;
resize: none;
}
.d-editor-preview {
height: auto;
}
.d-editor-plugin {
display: flex;
flex: 1 1;
overflow: auto;
}
.composing-whisper .d-editor-preview {
font-style: italic;
color: var(--primary-medium) !important;
}
.hide-preview .d-editor-preview-wrapper {
display: none;
flex: 0;
}
.edit-category-tab-topic-template {
.emoji.btn {
display: none;
}
}
.user-preferences .bio-composer,
.group-form-bio,
.edit-category-tab-topic-template {
textarea {
width: 100%;
height: 100%;
min-height: 10em;
}
.local-dates.btn {
display: none;
}
.d-editor-container {
display: block;
}
.d-editor-textarea-wrapper {
border: 1px solid var(--primary-low);
}
.d-editor-preview-wrapper {
max-width: 100%;
margin: 0;
padding: 0;
}
.d-editor-preview {
background-color: var(--primary-very-low);
margin-top: 1em;
padding: 0.667em;
&:empty {
margin: 0;
padding: 0;
}
}
}
.user-preferences .bio-composer,
.group-form-bio {
padding: 10px;
border: 1px solid var(--primary-low);
}
.d-editor-preview img {
padding-bottom: 1.4em;
&.emoji,
&.avatar,
&.onebox-avatar,
&.site-icon {
padding-bottom: 0;
}
&.resizable {
object-fit: cover;
object-position: top;
}
}
.d-editor-preview .image-wrapper {
--resizer-height: 1.75em;
position: relative;
display: inline-block;
.desktop-view & {
// need the extra space on mobile because controls are always visible
padding-bottom: var(--resizer-height);
margin-bottom: calc(var(--resizer-height) * -1);
}
img {
padding-bottom: 0;
}
&:hover {
.button-wrapper {
opacity: 1;
}
}
.button-wrapper {
min-width: 10em;
width: 100%;
display: flex;
flex-wrap: wrap;
gap: 0 0.5em;
position: absolute;
height: var(--resizer-height);
bottom: 0;
left: 0;
opacity: 0;
transition: all 0.25s;
z-index: 1; // needs to be higher than image
background: var(--secondary); // for when images are wider than controls
&[editing] {
opacity: 1;
}
.scale-btn-container,
.alt-text-readonly-container,
.alt-text-edit-container {
background: var(--secondary);
display: flex;
height: var(--resizer-height);
align-items: center;
&[hidden] {
display: none;
}
}
.scale-btn {
color: var(--tertiary);
padding: 0 1em;
&:first-child,
&:last-child {
padding: 0;
}
&.active {
font-weight: bold;
color: var(--primary);
}
&:not(.active):hover {
text-decoration: underline;
cursor: pointer;
}
}
.alt-text-readonly-container {
flex: 1 1;
width: 100%;
.alt-text {
margin-right: 0.5em;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
max-width: 100%;
}
.alt-text-edit-btn {
cursor: pointer;
svg {
padding-right: 0.5em;
}
}
}
.alt-text-edit-container {
margin-top: 0.25em;
gap: 0 0.25em;
flex: 1;
.alt-text-input,
.alt-text-edit-ok,
.alt-text-edit-cancel {
height: var(--resizer-height);
}
.alt-text-input {
flex: 1;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin: 0;
}
.alt-text-edit-ok,
.alt-text-edit-cancel {
border: none;
width: var(--resizer-height);
svg {
margin: 0;
}
}
}
svg {
pointer-events: none;
}
}
}
.mobile-view .d-editor-preview .image-wrapper .button-wrapper {
opacity: 1;
}
// d-editor bar button sizing
.d-editor-button-bar {
display: flex;
align-items: center;
border-bottom: 1px solid var(--primary-low);
width: 100%;
box-sizing: border-box;
padding-left: 2px;
padding-right: 2px;
.d-editor-spacer {
height: 1em;
display: inline-block;
border-left: 1px solid var(--primary-low);
margin: 0 0.25em;
.mobile-view & {
display: none;
}
}
.btn:focus {
@include default-focus;
}
.btn {
margin: 0;
background-color: transparent;
color: var(--primary-medium);
.d-icon {
color: currentColor;
}
&:hover {
color: var(--primary-low);
}
}
// ensures items grow/shrink on mobile to fit available space
@include breakpoint(mobile-large) {
.btn {
flex-grow: 1;
flex-shrink: 1;
flex-basis: auto;
padding-left: 0.25em;
padding-right: 0.25em;
}
.select-kit.toolbar-popup-menu-options {
flex-grow: 1;
flex-basis: auto;
.select-kit-header .select-kit-header-wrapper {
justify-content: center;
}
}
}
}