Skip to content

Commit

Permalink
refactor: use object structure to represent library entries to display
Browse files Browse the repository at this point in the history
  • Loading branch information
elyukai committed Oct 4, 2024
1 parent d796992 commit 6d0057b
Show file tree
Hide file tree
Showing 23 changed files with 902 additions and 592 deletions.
271 changes: 0 additions & 271 deletions src/main_window/inlineLibrary/InlineLibrary.scss
Original file line number Diff line number Diff line change
@@ -1,274 +1,3 @@
.inline-library {
user-select: text;

* {
user-select: text;
}

::selection {
background: var(--selection-color);
color: var(--headings-color);
}

.info-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 16px;
flex-direction: column;

h2 {
margin: 0;
font: bold 18px/24px Alegreya;
text-transform: none;
color: var(--headings-color);
padding-left: 0;
text-indent: 0;
}

p {
color: var(--text-color);
margin-top: 4px;
font: 500 12px Alegreya Sans;
}
}

p,
ul {
font: 500 14px/22px Alegreya Sans;
letter-spacing: 0.04em;
}

p {
padding-left: 18px;
text-indent: -18px;

&.no-indent {
padding-left: 0;
text-indent: 0;
}
}

.no-indent p {
padding-left: 0;
text-indent: 0;
}

.always-indent p {
text-indent: 0;
}

ul {
&.race-variant-options,
&.profession-variants {
li > span {
&:first-child {
font-style: italic;
font-weight: 400;

&::after {
content: " ";
}
}
}
}

// &.profession-variants li > span:nth-child(2)::after,
// &.race-variant-options li > span:first-child::after {
// content: ": ";
// }
}

> p {
// text-indent: -10px;
// padding-left: 10px;

> span:first-child {
font-weight: bold;
}

&:last-child {
margin-bottom: 1px;
}

&.cultural-package,
&.extensions-title,
&.source {
margin-top: 22px;
}

&.cultural-package {
padding-left: 0;
text-indent: 0;
-webkit-hyphens: auto;
hyphens: auto;

span {
display: block;
}
}

&.skill-group {
span:first-child {
font-weight: 400;
font-style: italic;
}
}

&.profession-variants {
padding-left: 0;
text-indent: 0;
}

&.source span:first-child {
font-weight: 500;
}
}

> p,
li {
> span:last-child:not(:first-child) {
span.disabled {
text-decoration: line-through;
}

// span.tier:not(:last-child)::after,
// span.hard-break:not(:last-child)::after {
// content: "; ";
// }

// span:not(.tier):not(.hard-break):not(:last-child)::after {
// content: ", ";
// }
}
}

.rule {
color: #f1e6d4;
}

.note {
color: #477;
}

.warning {
color: #be1e37;
}

table {
margin: 15px 0;
font: 500 14px/22px Alegreya Sans;
letter-spacing: 0.04em;
}

table td {
padding: 0;
border: none;
height: auto;
}

table td:first-child {
color: var(--text-color);
padding-right: 15px;
width: 0;
}

table td:last-child {
color: var(--headings-color);
width: 100%;
}

.test {
display: flex;
align-items: center;
margin-top: 16px;
color: #f1e6d4;

div {
height: 32px;
width: 32px;
margin-right: 8px;
border-width: 2px;
border-style: solid;
font: 500 12px/28px Alegreya Sans SC;
text-align: center;
}

.ATTR_1 {
border-color: var(--courage-color);
}

.ATTR_2 {
border-color: var(--sagacity-color);
}

.ATTR_3 {
border-color: var(--intuition-color);
}

.ATTR_4 {
border-color: var(--charisma-color);
}

.ATTR_5 {
border-color: var(--dexterity-color);
}

.ATTR_6 {
border-color: var(--agility-color);
}

.ATTR_7 {
border-color: var(--constitution-color);
}

.ATTR_8 {
border-color: var(--strength-color);
}

.at {
border-color: #aa1b32;
}

.at,
.pa {
font-size: 15px;
}

.pa {
border-color: #005177;
}

.hr {
border-width: 1px 0 0;
color: #1e282d;
flex: 1 1 auto;
height: 1px;
margin-left: 2px;
margin-right: 10px;
}

.routine,
.primary {
border-color: #1e282d;
border-width: 1px;
margin-right: 0;
color: #878683;
line-height: 30px;
}

.primary {
width: auto;
min-width: 32px;
padding: 0 8px;
}
}

.subtitle {
margin-top: 2px;
}
}

.inline-library-placeholder {
flex: 1 1 100%;
justify-content: center;
Expand Down
5 changes: 4 additions & 1 deletion src/main_window/inlineLibrary/InlineLibrary.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FC } from "react"
import { Aside } from "../../shared/components/aside/Aside.tsx"
import { Scroll } from "../../shared/components/scroll/Scroll.tsx"
import { useAppSelector } from "../hooks/redux.ts"
import { selectInlineLibraryEntryId } from "../slices/inlineWikiSlice.ts"
import "./InlineLibrary.scss"
Expand All @@ -14,7 +15,9 @@ export const InlineLibrary: FC = () => {

return (
<Aside className="inline-library">
{id === undefined ? <InlineLibraryPlaceholder /> : <InlineLibraryRouter id={id} />}
<Scroll>
{id === undefined ? <InlineLibraryPlaceholder /> : <InlineLibraryRouter id={id} />}
</Scroll>
</Aside>
)
}
30 changes: 0 additions & 30 deletions src/main_window/inlineLibrary/InlineLibraryProperties.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { FC } from "react"
import { useTranslate } from "../../../shared/hooks/translate.ts"
import { useTranslateMap } from "../../../shared/hooks/translateMap.ts"
import { LibraryEntry } from "../../../shared/components/libraryEntry/LibraryEntry.tsx"
import { getExperienceLevelLibraryEntry } from "../../../shared/domain/experienceLevel.ts"
import { useAppSelector } from "../../hooks/redux.ts"
import { selectStaticExperienceLevels } from "../../slices/databaseSlice.ts"
import { InlineLibraryPlaceholder } from "../InlineLibraryPlaceholder.tsx"
import { InlineLibraryProperties } from "../InlineLibraryProperties.tsx"
import { InlineLibraryTemplate } from "../InlineLibraryTemplate.tsx"

type Props = {
id: number
Expand All @@ -15,50 +12,7 @@ type Props = {
* Displays all information about an experience level.
*/
export const InlineLibraryExperienceLevel: FC<Props> = ({ id }) => {
const translate = useTranslate()
const translateMap = useTranslateMap()

const entry = useAppSelector(selectStaticExperienceLevels)[id]
const translation = translateMap(entry?.translations)

if (entry === undefined || translation === undefined) {
return <InlineLibraryPlaceholder />
}

return (
<InlineLibraryTemplate className="experience-level" title={translation.name}>
<InlineLibraryProperties
list={[
{
label: translate("Adventure Points"),
value: entry.adventure_points,
},
{
label: translate("Maximum Attribute Value"),
value: entry.max_attribute_value,
},
{
label: translate("Maximum Skill Value"),
value: entry.max_skill_rating,
},
{
label: translate("Maximum Combat Technique"),
value: entry.max_combat_technique_rating,
},
{
label: translate("Maximum Attribute Total"),
value: entry.max_attribute_total,
},
{
label: translate("Number of Spells/Liturgical Chants"),
value: entry.max_number_of_spells_liturgical_chants,
},
{
label: translate("Number from other Traditions"),
value: entry.max_number_of_unfamiliar_spells,
},
]}
/>
</InlineLibraryTemplate>
)
return <LibraryEntry createLibraryEntry={getExperienceLevelLibraryEntry(entry)} />
}
Loading

0 comments on commit 6d0057b

Please sign in to comment.