Skip to content

Commit

Permalink
Add TipTap integration in PHP and Vue + Tera LandTask typescript sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-de-pachtere committed Feb 5, 2025
1 parent 02f811c commit aa5f39b
Show file tree
Hide file tree
Showing 50 changed files with 2,375 additions and 243 deletions.
20 changes: 0 additions & 20 deletions .idea/lychen.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions libs/php/util-tiptap/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
22 changes: 22 additions & 0 deletions libs/php/util-tiptap/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "lychen/util-tiptap",
"type": "library",
"autoload": {
"psr-4": {
"Lychen\\UtilTiptap\\": "src/"
}
},
"authors": [
{
"name": "Nathan De Pachtere",
"email": "[email protected]"
}
],
"minimum-stability": "stable",
"require": {
"ueberdosis/tiptap-php": "1.4.*"
},
"require-dev": {
"zenstruck/foundry": "2.2.*"
}
}
5 changes: 5 additions & 0 deletions libs/php/util-tiptap/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id: lychen-php-util-tiptap

language: php

type: library
49 changes: 49 additions & 0 deletions libs/php/util-tiptap/src/Service/TipTapFaker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Lychen\UtilTiptap\Service;

use function Zenstruck\Foundry\faker;

class TipTapFaker
{
public static function randomContent(): ?array
{
return faker()->boolean ? TipTapFaker::sentences() : TipTapFaker::paragraphs();
}

public static function sentences($min = 1, $max = 3, $random = true): ?array
{
return (!$random || faker()->boolean(70)) ? [
'type' => 'doc',
'content' => [
[
'type' => 'paragraph',
'content' => [
[
'type' => 'text',
'text' => faker()->sentences(faker()->biasedNumberBetween($min, $max), asText: true),
],
],
],
],
] : null;
}

public static function paragraphs($min = 1, $max = 3, $random = true): ?array
{
return (!$random || faker()->boolean(70)) ? [
'type' => 'doc',
'content' => [
[
'type' => 'paragraph',
'content' => [
[
'type' => 'text',
'text' => faker()->paragraph(faker()->biasedNumberBetween($min, $max)),
],
],
],
],
] : null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<template>
<div
class="p-4 rounded-3xl bg-surface-container-high text-on-surface-container flex flex-row gap-4 justify-between items-center active:bg-surface-container-highest"
>
<div class="flex flex-col gap-1">
<span class="whitespace-nowrap overflow-hidden text-ellipsis text-sm"
>{{ landTask.title }}
</span>
<span
v-if="landTask.startDate || landTask.dueDate"
class="opacity-70 text-xs"
>
{{
landTask.startDate && !landTask.dueDate
? 'Débute le'
: !landTask.startDate && landTask.dueDate
? 'Dû le'
: 'Du'
}}
<span v-if="landTask.startDate">{{ d(landTask.startDate, 'short') }}</span>
{{ landTask.startDate && landTask.dueDate ? 'au' : '' }}
<span
v-if="landTask.dueDate"
:class="{ 'text-negative': overdue }"
>{{ d(landTask.dueDate, 'short') }}</span
>
</span>
</div>
</div>
</template>

<script generic="T extends Land" lang="ts" setup>
import type { Land } from '@lychen/tera-util-api-sdk/model/Land';
import { computed, defineAsyncComponent } from 'vue';
import { messages, TRANSLATION_KEY } from '@lychen/tera-land-ui-i18n/property';
import { useI18nExtended } from '@lychen/vue-i18n-util-composables/useI18nExtended';
import { VARIANT, type Variant } from '.';
import type { LandTask } from '@lychen/tera-util-api-sdk/model/LandTask';
const LychenIcon = defineAsyncComponent(() => import('@lychen/ui-components/icon/LychenIcon.vue'));
const { variant = VARIANT.Default, landTask } = defineProps<{
landTask: Required<Pick<LandTask, 'title' | 'content' | 'dueDate' | 'startDate'>>;
variant?: Variant;
}>();
const { t, d } = useI18nExtended({ messages, rootKey: TRANSLATION_KEY, prefixed: true });
const overdue = computed<boolean>(() => {
return new Date(landTask.dueDate) < new Date();
});
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { ObjectValues } from '@lychen/typescript-util-object/Object';

export const VARIANT = {
Default: 'default',
} as const;

export type Variant = ObjectValues<typeof VARIANT>;
9 changes: 9 additions & 0 deletions libs/tera/land-task/ui-components/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependsOn:
- tera-land-task-ui-i18n
- tera-util-api-sdk
- typescript-util-object
- ui-components

id: tera-land-task-ui-components
language: typescript
type: library
11 changes: 11 additions & 0 deletions libs/tera/land-task/ui-components/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@lychen/tera-land-task-ui-components",
"version": "0.0.0",
"license": "UNLICENSED",
"dependencies": {
"@lychen/tera-land-task-ui-i18n": "workspace:*",
"@lychen/tera-util-api-sdk": "workspace:*",
"@lychen/typescript-util-object": "workspace:*",
"@lychen/ui-components": "workspace:*"
}
}
33 changes: 33 additions & 0 deletions libs/tera/land-task/ui-components/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": "../../../../tsconfig.options.json",
"include": [
"../../../typescript/util-object/**/*",
"../../../ui-components/**/*",
"../../util-api-sdk/**/*",
"../ui-i18n/**/*",
"**/*"
],
"references": [
{
"path": "../../../typescript/util-object"
},
{
"path": "../../../ui-components"
},
{
"path": "../../util-api-sdk"
},
{
"path": "../ui-i18n"
}
],
"compilerOptions": {
"outDir": "../../../../.moon/cache/types/libs/tera/land-task/ui-components",
"paths": {
"@lychen/ui-components/*": ["../../../ui-components/*"],
"@lychen/tera-util-api-sdk/*": ["../../util-api-sdk/*"],
"@lychen/typescript-util-object/*": ["../../../typescript/util-object/*"],
"@lychen/tera-land-task-ui-i18n/*": ["../ui-i18n/*"]
}
}
}
3 changes: 3 additions & 0 deletions libs/tera/land-task/ui-i18n/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id: tera-land-task-ui-i18n
language: typescript
type: library
5 changes: 5 additions & 0 deletions libs/tera/land-task/ui-i18n/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@lychen/tera-land-task-ui-i18n",
"version": "0.0.0",
"license": "UNLICENSED"
}
22 changes: 22 additions & 0 deletions libs/tera/land-task/ui-i18n/property/en-US.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default {
land_areas: {
default: 'no area | 1 area | {count} areas',
},
kind: {
label: 'Type of space',
individual: {
default: 'Individual',
},
market_garden: {
default: 'Market garden',
},
shared_garden: {
default: 'Shared garden',
},
},
surface: {
label: 'Surface area',
suffix: 'in m²',
default: '{count} m²',
},
};
22 changes: 22 additions & 0 deletions libs/tera/land-task/ui-i18n/property/fr-FR.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default {
land_areas: {
default: 'aucune zone | 1 zone | {count} zones',
},
kind: {
label: "Type d'espace",
individual: {
default: 'Particulier',
},
market_garden: {
default: 'Maraîcher',
},
shared_garden: {
default: 'Jardin partagé',
},
},
surface: {
label: 'Surface',
suffix: 'en m²',
default: '{count} m²',
},
};
10 changes: 10 additions & 0 deletions libs/tera/land-task/ui-i18n/property/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import enUs from './en-US';
import frFr from './fr-FR';

export const messages = {
'fr-FR': frFr,
'en-US': enUs,
'en-GB': enUs,
};

export const TRANSLATION_KEY = 'lychen_tera_land_property';
9 changes: 9 additions & 0 deletions libs/tera/land-task/ui-i18n/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.options.json",
"include": ["**/*"],
"references": [],
"compilerOptions": {
"outDir": "../../../../.moon/cache/types/libs/tera/land-task/ui-i18n",
"paths": {}
}
}
3 changes: 3 additions & 0 deletions libs/tera/land-task/util-composables/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id: tera-land-task-util-composables
language: typescript
type: library
9 changes: 9 additions & 0 deletions libs/tera/land-task/util-composables/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../../tsconfig.options.json",
"include": ["**/*"],
"references": [],
"compilerOptions": {
"outDir": "../../../../.moon/cache/types/libs/tera/land-task/util-composables",
"paths": {}
}
}
18 changes: 18 additions & 0 deletions libs/tera/util-api-sdk/model/LandTask.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Resource } from '@lychen/typescript-util-json-ld-hydra/types/Resource';
import { instanceOfResource } from '@lychen/typescript-util-json-ld-hydra/types/Resource';

export interface LandTask extends Resource {
'@type': 'LandTask';
title: string;
content?: JSON;
dueDate?: string;
startDate?: string;
}

export function instanceOfLandTask(object: unknown): object is LandTask {
if (!instanceOfResource(object)) {
return false;
}

return object['@type'] === 'LandTask';
}
8 changes: 8 additions & 0 deletions libs/tera/util-api-sdk/repositories/LandTaskRepository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Repository } from '@lychen/typescript-util-api/classes/Repository';
import axiosInstance from '@lychen/typescript-util-api/ZitadelBearerTokenAxiosInstance';
import type { Resource } from '@lychen/typescript-util-json-ld-hydra/types/Resource';
import type { LandTask } from '../model/LandTask';

class LandTaskRepository<T extends Resource = LandTask> extends Repository<T> {}

export default new LandTaskRepository(axiosInstance, 'land_tasks');
1 change: 1 addition & 0 deletions libs/typescript/util-types/Utility.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type OrNullUndefined<T> = T | null | undefined;
3 changes: 3 additions & 0 deletions libs/typescript/util-types/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id: typescript-util-types
language: typescript
type: library
5 changes: 5 additions & 0 deletions libs/typescript/util-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@lychen/typescript-util-types",
"version": "0.0.0",
"license": "UNLICENSED"
}
9 changes: 9 additions & 0 deletions libs/typescript/util-types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../tsconfig.options.json",
"include": ["**/*"],
"references": [],
"compilerOptions": {
"outDir": "../../../.moon/cache/types/libs/typescript/util-types",
"paths": {}
}
}
2 changes: 2 additions & 0 deletions libs/ui-components/icon/AppLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { faMicrophone } from '@fortawesome/pro-light-svg-icons/faMicrophone';
import { faKeyboard } from '@fortawesome/pro-light-svg-icons/faKeyboard';
import { faCamera } from '@fortawesome/pro-light-svg-icons/faCamera';
import { faEllipsisVertical } from '@fortawesome/pro-light-svg-icons/faEllipsisVertical';
import { faCalendarCircleExclamation } from '@fortawesome/pro-light-svg-icons/faCalendarCircleExclamation';

import { library } from '@fortawesome/fontawesome-svg-core';

Expand Down Expand Up @@ -75,6 +76,7 @@ export function loadFontAwesomeStyles() {
faKeyboard,
faCamera,
faEllipsisVertical,
faCalendarCircleExclamation,
]);
library.add(faGithub);
library.add(faDiscord);
Expand Down
1 change: 1 addition & 0 deletions libs/vue/tiptap/ui-components/TipTapEditor.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type NoStylingProps = { noStyling?: boolean };
Loading

0 comments on commit aa5f39b

Please sign in to comment.