aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index b160379df..1c57c5d63 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -498,6 +498,12 @@ export class DocumentOptions {
hoverBackgroundColor?: string; // background color of a label when hovered
userBackgroundColor?: STRt = new StrInfo('background color associated with a Dash user (seen in header fields of shared documents)');
userColor?: STRt = new StrInfo('color associated with a Dash user (seen in header fields of shared documents)');
+
+ card_sort_time?: BOOLt = new BoolInfo('whether sorting cards in deck view by time');
+ card_sort_type?: BOOLt = new BoolInfo('whether sorting cards in deck view by type');
+ card_sort_color?: BOOLt = new BoolInfo('whether sorting cards in deck view by color');
+
+
}
export const DocOptions = new DocumentOptions();
@@ -1216,6 +1222,8 @@ export namespace Docs {
);
}
+
+
export function LinearDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) {
return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Linear }, id);
}
@@ -1232,6 +1240,10 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Carousel3D });
}
+ export function CardDeckDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) {
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Card});
+ }
+
export function SchemaDocument(schemaHeaders: SchemaHeaderField[], documents: Array<Doc>, options: DocumentOptions) {
return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { schemaHeaders: new List(schemaHeaders), ...options, _type_collection: CollectionViewType.Schema });
}
@@ -1881,6 +1893,45 @@ export namespace DocUtils {
return newCollection;
}
}
+
+ export function spreadCards(docList: Doc[], x: number = 0, y: number = 0, spreadAngle: number = 30, radius: number = 100, create: boolean = true) {
+ console.log('spread cards');
+ const totalCards = docList.length;
+ const halfSpreadAngle = spreadAngle * 0.5;
+ const angleStep = spreadAngle / (totalCards - 1);
+
+ runInAction(() => {
+ docList.forEach((d, i) => {
+ DocUtils.iconify(d);
+ const angle = (-halfSpreadAngle + angleStep * i) * (Math.PI / 180); // Convert degrees to radians
+ d.x = x + Math.cos(angle) * radius;
+ d.y = y + Math.sin(angle) * radius;
+ d.rotation = angle;
+ d._timecodeToShow = undefined;
+ });
+ });
+
+ if (create) {
+ const newCollection = Docs.Create.CardDeckDocument(docList, {
+ title: 'card-spread',
+ _freeform_noZoom: true,
+ x: x - radius,
+ y: y - radius,
+ _width: radius * 2,
+ _height: radius * 2,
+ dragWhenActive: true,
+ _layout_fitWidth: false
+ });
+ // Adjust position based on the collection's dimensions if needed
+ newCollection.x = NumCast(newCollection.x) + NumCast(newCollection._width) / 2 - radius;
+ newCollection.y = NumCast(newCollection.y) + NumCast(newCollection._height) / 2 - radius;
+ newCollection._width = newCollection._height = radius * 2;
+ return newCollection;
+ }
+ }
+
+
+
export function makeIntoPortal(doc: Doc, layoutDoc: Doc, allLinks: Doc[]) {
const portalLink = allLinks.find(d => d.link_anchor_1 === doc && d.link_relationship === 'portal to:portal from');
if (!portalLink) {