-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
195 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useEffect, useRef } from "react"; | ||
|
||
export const useIsOverflowing = ( | ||
key: boolean, | ||
setIsOverflowing: (is: boolean) => void, | ||
) => { | ||
const ref = useRef<any>(null); | ||
|
||
useEffect(() => { | ||
const current = ref.current; | ||
if (current) { | ||
const isContentOverflowing = current.scrollHeight > current.clientHeight; | ||
setIsOverflowing(isContentOverflowing); | ||
} | ||
}, [setIsOverflowing, ref, key]); | ||
|
||
return { setIsOverflowing, ref }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { CardPreview } from "../deck-form/card-preview.tsx"; | ||
import { useState } from "react"; | ||
import { CardFormStoreInterface } from "../deck-form/store/card-form-store-interface.ts"; | ||
import { TextField } from "../../lib/mobx-form/text-field.ts"; | ||
import { CardAnswerType } from "../../../functions/db/custom-types.ts"; | ||
import { BooleanToggle } from "../../lib/mobx-form/boolean-toggle.ts"; | ||
import { CardAnswerFormType } from "../deck-form/store/deck-form-store.ts"; | ||
import { ListField } from "../../lib/mobx-form/list-field.ts"; | ||
|
||
const createCardPreviewForm = (card: { | ||
front: string; | ||
back: string; | ||
example?: string; | ||
}): CardFormStoreInterface => { | ||
return { | ||
cardForm: { | ||
front: new TextField<string>(card.front), | ||
back: new TextField<string>(card.back), | ||
example: new TextField<string>(card.example ?? ""), | ||
answerType: new TextField<CardAnswerType>("remember"), | ||
answerFormType: "new", | ||
answers: new ListField<CardAnswerFormType>([]), | ||
answerId: "0", | ||
}, | ||
form: undefined, | ||
isCardPreviewSelected: new BooleanToggle(false), | ||
isSaveCardButtonActive: false, | ||
onBackCard: () => {}, | ||
onSaveCard: () => {}, | ||
isSending: false, | ||
markCardAsRemoved: () => {}, | ||
}; | ||
}; | ||
|
||
export const CardPreviewStory = (props: { | ||
card: { | ||
front: string; | ||
back: string; | ||
example?: string; | ||
}; | ||
}) => { | ||
const [form] = useState(createCardPreviewForm(props.card)); | ||
|
||
return <CardPreview form={form} onBack={() => {}} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Screen } from "../shared/screen.tsx"; | ||
import { useState } from "react"; | ||
import { useBackButton } from "../../lib/telegram/use-back-button.tsx"; | ||
import { css } from "@emotion/css"; | ||
import { theme } from "../../ui/theme.tsx"; | ||
import { Component, components } from "./components.tsx"; | ||
|
||
export const ComponentCatalogPage = () => { | ||
const [selectedComponent, setSelectedComponent] = useState<Component | null>( | ||
null, | ||
); | ||
useBackButton(() => { | ||
setSelectedComponent(null); | ||
}); | ||
|
||
if (selectedComponent) { | ||
return selectedComponent.component; | ||
} | ||
|
||
return ( | ||
<Screen title={"Component catalog"}> | ||
<ul> | ||
{components.map((component) => ( | ||
<li | ||
key={component.name} | ||
onClick={() => setSelectedComponent(component)} | ||
className={css({ | ||
cursor: "pointer", | ||
color: theme.linkColor, | ||
})} | ||
> | ||
{component.name} | ||
</li> | ||
))} | ||
</ul> | ||
</Screen> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Button } from "../../ui/button.tsx"; | ||
import { ReactNode } from "react"; | ||
import { CardPreviewStory } from "./card-preview-story.tsx"; | ||
|
||
export type Component = { name: string; component: ReactNode }; | ||
|
||
export const components: Array<Component> = [ | ||
{ | ||
name: "Button", | ||
component: <Button>Button</Button>, | ||
}, | ||
|
||
{ | ||
name: "Button - outline", | ||
component: <Button outline>Button</Button>, | ||
}, | ||
{ | ||
name: "Card preview - normal", | ||
component: ( | ||
<CardPreviewStory | ||
card={{ | ||
example: "Example", | ||
back: "Back", | ||
front: "Front", | ||
}} | ||
/> | ||
), | ||
}, | ||
{ | ||
name: "Card preview - big text", | ||
component: ( | ||
<CardPreviewStory | ||
card={{ | ||
example: "Example", | ||
front: "Front", | ||
// eslint-disable-next-line | ||
back: `<ul><li>FAS-Risiko</li><li>viele Eltern meiden den Kontakt zum Hilfesystem</li><li>keine verlässliche Bezugsperson/häufiger Wechsel</li><li>Erleben von Armut/Arbeitslosigkeit/beengten Wohnverhältnissen</li><li>desolater elterlicher Gesundheitszustand/Notfälle/Sorge um die Eltern</li><li>Gefährdung durch elterliche Intoxikation (direkte Gewalterfahrung oder Zeugenschaft)</li><li>Familienklima: Familiengeheimnisse, Tabuisierungen, Loyalitätskon-flikte</li><li>kindliche Verhaltensauffälligkeiten (Hyperaktivität, Angste, Rückzug, extrem schüchtern)</li><li>typische Rollen und Familienregeln (Umkreisen und Verschweigen des Alkoholthemas)</li><li>Familienstruktur: aufgeweichte Generationsgrenzen, altersunangemes-sene Aufgaben,</li><li>erhöhte Gefahr emotionalen/sexuellen Mißbrauchs</li></ul><p>grundlegende Stressoren:</p><ul><li>elterliche Unzuverlässigkeit</li><li>Bindungsstörungen: unsicher, ambivalent</li><li>Duldungs- und Katastrophenstress</li><li>Krisenstress (bei Unfähigkeit zur Problembewältigung)</li><li>überfordernde Aufgaben und Rollen</li></ul><p>Quelle: GVS (2012, 2014)</p>`, | ||
}} | ||
/> | ||
), | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.