Skip to content

Commit

Permalink
chore: adjust css for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentdchan committed Dec 6, 2023
1 parent 5578261 commit 7081333
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 38 deletions.
23 changes: 23 additions & 0 deletions packages/blocky-core/css/blocky-core.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
font-size: 32px;
font-weight: 700;
color: var(--blocky-primary-color);
padding-left: 56px;
padding-right: 56px;
}

.blocky-editor-title-container:empty::before {
Expand Down Expand Up @@ -230,3 +232,24 @@
left: 0px;
height: 2px;
}

.blocky-editor-blocks-container {
padding: 12px 56px 72px;
}


@media only screen and (max-width: 600px) {

.blocky-editor-title-container {
font-size: 32px;
font-weight: 700;
color: var(--blocky-primary-color);
padding-left: 42px;
padding-right: 42px;
}

.blocky-editor-blocks-container {
padding: 12px 42px 72px;
}

}
6 changes: 0 additions & 6 deletions packages/blocky-core/src/view/controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { isUpperCase } from "blocky-common/es";
import { Subject } from "rxjs";
import { type Padding } from "blocky-common/es/dom";
import { EditorState, NodeTraverser } from "@pkg/model";
import {
AttributesObject,
Expand Down Expand Up @@ -90,11 +89,6 @@ export interface IEditorControllerOptions {
idGenerator?: IdGenerator;
toolbarFactory?: ToolbarFactory;

/**
* The inner padding of the editor
*/
padding?: Partial<Padding>;

collaborativeCursorFactory?: CollaborativeCursorFactory;

emptyPlaceholder?: string;
Expand Down
21 changes: 1 addition & 20 deletions packages/blocky-core/src/view/editor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isContainNode, removeNode, type Padding } from "blocky-common/es/dom";
import { isContainNode, removeNode } from "blocky-common/es/dom";
import {
isUpperCase,
areEqualShallow,
Expand Down Expand Up @@ -84,7 +84,6 @@ export interface IEditorOptions {
container: HTMLDivElement;
idGenerator?: IdGenerator;
toolbarFactory?: ToolbarFactory;
padding?: Partial<Padding>;
collaborativeCursorFactory?: CollaborativeCursorFactory;
}

Expand All @@ -93,15 +92,6 @@ enum MineType {
Html = "text/html",
}

function makeDefaultPadding(): Padding {
return {
top: 12,
right: 56,
bottom: 72,
left: 56,
};
}

interface BlockSizeInfo {
id: string;
rect: DOMRect;
Expand Down Expand Up @@ -201,8 +191,6 @@ export class Editor {

readonly collaborativeCursorManager: CollaborativeCursorManager;

readonly padding: Padding;

composing = false;
private disposables: IDisposable[] = [];

Expand All @@ -219,7 +207,6 @@ export class Editor {
},
state: controller.state,
toolbarFactory: controller.options?.toolbarFactory,
padding: controller.options?.padding,
collaborativeCursorFactory:
controller.options?.collaborativeCursorFactory,
});
Expand All @@ -234,19 +221,13 @@ export class Editor {
registry,
idGenerator,
toolbarFactory,
padding,
collaborativeCursorFactory,
} = options;
this.state = state;
this.registry = registry;
this.container = container;
this.idGenerator = idGenerator ?? makeDefaultIdGenerator();

this.padding = {
...makeDefaultPadding(),
...padding,
};

this.collaborativeCursorManager = new CollaborativeCursorManager(
collaborativeCursorFactory
);
Expand Down
12 changes: 1 addition & 11 deletions packages/blocky-core/src/view/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ export class DocRenderer {
"div",
`${clsPrefix}-editor-title-container ${this.blockClassName}`,
(elem: HTMLElement) => {
const { padding } = this.editor;
const { right, left } = padding;
elem.style.paddingLeft = `${left}px`;
elem.style.paddingRight = `${right}px`;

if (this.editor.controller?.options?.titleEditable === false) {
elem.contentEditable = "false";
}
Expand All @@ -187,12 +182,7 @@ export class DocRenderer {
dom,
renderCounter++,
"div",
`${clsPrefix}-editor-blocks-container`,
(elem: HTMLElement) => {
const { padding } = this.editor;
const { top, right, bottom, left } = padding;
elem.style.padding = `${top}px ${right}px ${bottom}px ${left}px`;
}
`${clsPrefix}-editor-blocks-container`
);

this.renderBlocks(
Expand Down
2 changes: 1 addition & 1 deletion packages/blocky-example/app/loro/loroBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function LoroBlock(props: LoroBlockProps) {
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={handleClose}>Canel</Button>
<Button onClick={handleClose}>Cancel</Button>
<Button onClick={handleConfirm} color="error" autoFocus>
Confirm
</Button>
Expand Down
1 change: 1 addition & 0 deletions packages/blocky-example/app/loro/loroExample.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

:global(.blocky-editor-container) {
flex: 1;
max-width: 100%;
}

:global(.blocky-documents) {
Expand Down

1 comment on commit 7081333

@vercel
Copy link

@vercel vercel bot commented on 7081333 Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.