diff --git a/docs/src/lib/styles/github.scss b/docs/src/lib/styles/github.scss index b83daaf8..de199f17 100644 --- a/docs/src/lib/styles/github.scss +++ b/docs/src/lib/styles/github.scss @@ -77,6 +77,35 @@ } } + .carta-icons-menu { + padding: 8px; + border: 1px solid $border; + border-radius: 6px; + min-width: 180px; + background: $background; + + .carta-icon-full { + padding-left: 6px; + padding-right: 6px; + + margin-top: 2px; + &:first-child { + margin-top: 0; + } + + &:hover { + color: white; + background-color: $border; + } + + span { + margin-left: 6px; + color: white; + font-size: 0.85rem; + } + } + } + [class*='shj-lang-'] { background: transparent; } diff --git a/docs/src/lib/styles/math-stack-exchange.scss b/docs/src/lib/styles/math-stack-exchange.scss index 73ec59e4..180786f9 100644 --- a/docs/src/lib/styles/math-stack-exchange.scss +++ b/docs/src/lib/styles/math-stack-exchange.scss @@ -70,6 +70,35 @@ } } + .carta-icons-menu { + padding: 8px; + border: 1px solid $border; + border-radius: 6px; + min-width: 180px; + background: $background; + + .carta-icon-full { + padding-left: 6px; + padding-right: 6px; + + margin-top: 2px; + &:first-child { + margin-top: 0; + } + + &:hover { + color: white; + background-color: $border; + } + + span { + margin-left: 6px; + color: white; + font-size: 0.85rem; + } + } + } + &.carta-viewer { min-height: 60px; padding: 1rem; diff --git a/packages/carta-md/src/lib/CartaEditor.svelte b/packages/carta-md/src/lib/CartaEditor.svelte index 43ab6e14..9dc20e83 100644 --- a/packages/carta-md/src/lib/CartaEditor.svelte +++ b/packages/carta-md/src/lib/CartaEditor.svelte @@ -6,7 +6,7 @@ import { debounce } from './internal/utils'; import type { TextAreaProps } from './internal/textarea-props'; import { DefaultCartaLabels, type CartaLabels } from './internal/labels'; - import { handleArrowKeysNavigation } from './internal/accessibility'; + import Toolbar from './internal/components/Toolbar.svelte'; export let carta: Carta; export let theme = 'default'; @@ -28,13 +28,11 @@ let selectedTab: 'write' | 'preview' = 'write'; let windowMode: 'tabs' | 'split'; let mounted = false; - let hideIcons = false; let resizeInput: () => void; onMount(() => (mounted = true)); $: { windowMode = mode === 'auto' ? (width > 768 ? 'split' : 'tabs') : mode; - hideIcons = width < 576; } $: { @@ -100,50 +98,7 @@
{#if !disableToolbar} - + {/if}
@@ -201,17 +156,11 @@ flex-direction: column; } - .carta-toolbar { - height: 2rem; - display: flex; - flex-shrink: 0; - } - - :global(.mode-split > *) { + :global(.carta-container.mode-split > *) { width: 50%; } - :global(.mode-tabs > *) { + :global(.carta-container.mode-tabs > *) { width: 100%; } @@ -219,27 +168,4 @@ display: flex; position: relative; } - - .carta-toolbar-left { - height: 100%; - } - - .carta-toolbar-right { - height: 100%; - flex-grow: 1; - display: flex; - align-items: center; - justify-content: flex-end; - } - - .carta-icon { - display: flex; - align-items: center; - justify-content: center; - width: 1.5rem; - height: 1.5rem; - border-radius: 3px; - cursor: pointer; - margin-left: 4px; - } diff --git a/packages/carta-md/src/lib/default.css b/packages/carta-md/src/lib/default.css index dac1fc61..d18bde17 100644 --- a/packages/carta-md/src/lib/default.css +++ b/packages/carta-md/src/lib/default.css @@ -70,12 +70,22 @@ } /* Icons */ -.carta-theme__default .carta-icon { +.carta-theme__default .carta-icon, +.carta-theme__default .carta-icon-full { border: 0; background: transparent; } -.carta-theme__default .carta-icon:hover { +.carta-theme__default .carta-icon-full { + padding: 6px 4px; +} + +.carta-theme__default .carta-icon-full span { + margin-left: 6px; +} + +.carta-theme__default .carta-icon:hover, +.carta-theme__default .carta-icon-full:hover { background: var(--hover-color); } @@ -83,6 +93,21 @@ background: inherit; } +.carta-theme__default .carta-icons-menu { + padding: 6px; + border: 1px solid var(--border-color); + border-radius: 6px; + min-width: 180px; +} + +.carta-theme__default .carta-icons-menu .carta-icon-full { + margin-top: 2px; +} + +.carta-theme__default .carta-icons-menu .carta-icon-full:first-child { + margin-top: 0; +} + /* Buttons */ .carta-theme__default .carta-toolbar-left button { background: none; diff --git a/packages/carta-md/src/lib/internal/components/Toolbar.svelte b/packages/carta-md/src/lib/internal/components/Toolbar.svelte new file mode 100644 index 00000000..87697a4b --- /dev/null +++ b/packages/carta-md/src/lib/internal/components/Toolbar.svelte @@ -0,0 +1,195 @@ + + + + +