Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.demcha.compose.document.templates.cv.v2.data;
package com.demcha.compose.document.templates.core.identity;

import java.util.Objects;

Expand All @@ -13,12 +13,12 @@
* @param email non-blank email (rendered as a clickable mailto link)
* @param address non-blank location / postal address line
*/
public record CvContact(String phone, String email, String address) {
public record Contact(String phone, String email, String address) {

/**
* Validates that every field is non-null and non-blank.
*/
public CvContact {
public Contact {
Objects.requireNonNull(phone, "phone");
Objects.requireNonNull(email, "email");
Objects.requireNonNull(address, "address");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.demcha.compose.document.templates.cv.v2.widgets;
package com.demcha.compose.document.templates.core.identity;

import com.demcha.compose.document.dsl.SectionBuilder;
import com.demcha.compose.document.node.DocumentLinkOptions;
import com.demcha.compose.document.node.TextAlign;
import com.demcha.compose.document.style.DocumentInsets;
import com.demcha.compose.document.style.DocumentTextStyle;
import com.demcha.compose.document.templates.cv.v2.data.CvContact;
import com.demcha.compose.document.templates.cv.v2.data.CvIdentity;
import com.demcha.compose.document.templates.cv.v2.data.CvLink;
import com.demcha.compose.document.templates.core.theme.BrandTheme;

import java.util.ArrayList;
Expand All @@ -34,7 +31,7 @@
* </ul>
*
* <p>Email is always rendered as a clickable {@code mailto:} link;
* each optional {@link CvLink} becomes a clickable hyperlink with
* each optional {@link Link} becomes a clickable hyperlink with
* the {@code label} as the visible text. The separator glyph comes
* from {@code theme.decoration().contactSeparator()}.</p>
*/
Expand All @@ -52,14 +49,14 @@ private ContactLine() {
* @param identity the CV identity supplying contact fields and links
* @param theme the active theme supplying palette, typography, and spacing
*/
public static void centered(SectionBuilder host, CvIdentity identity, BrandTheme theme) {
public static void centered(SectionBuilder host, PartyIdentity identity, BrandTheme theme) {
render(host, identity, theme, TextAlign.CENTER, Order.PHONE_FIRST);
}

/**
* Centred contact row with explicit text-style overrides for
* non-link text, clickable links, and separators. Same ordering as
* {@link #centered(SectionBuilder, CvIdentity, BrandTheme)}, but lets
* {@link #centered(SectionBuilder, PartyIdentity, BrandTheme)}, but lets
* editorial presets tint / underline the links without forking the
* contact assembly logic.
*
Expand All @@ -76,7 +73,7 @@ public static void centered(SectionBuilder host, CvIdentity identity, BrandTheme
* {@code null} →
* {@code theme.contactSeparatorStyle()}
*/
public static void centered(SectionBuilder host, CvIdentity identity,
public static void centered(SectionBuilder host, PartyIdentity identity,
BrandTheme theme,
DocumentTextStyle bodyStyleOverride,
DocumentTextStyle linkStyleOverride,
Expand All @@ -94,7 +91,7 @@ public static void centered(SectionBuilder host, CvIdentity identity,
* @param identity the CV identity supplying contact fields and links
* @param theme the active theme supplying palette, typography, and spacing
*/
public static void rightAligned(SectionBuilder host, CvIdentity identity, BrandTheme theme) {
public static void rightAligned(SectionBuilder host, PartyIdentity identity, BrandTheme theme) {
render(host, identity, theme, TextAlign.RIGHT, Order.ADDRESS_FIRST);
}

Expand All @@ -107,7 +104,7 @@ public static void rightAligned(SectionBuilder host, CvIdentity identity, BrandT
* @param identity the CV identity supplying contact fields and links
* @param theme the active theme supplying palette, typography, and spacing
*/
public static void leftAligned(SectionBuilder host, CvIdentity identity,
public static void leftAligned(SectionBuilder host, PartyIdentity identity,
BrandTheme theme) {
render(host, identity, theme, TextAlign.LEFT, Order.ADDRESS_FIRST);
}
Expand All @@ -129,7 +126,7 @@ public static void leftAligned(SectionBuilder host, CvIdentity identity,
* {@code null} ->
* {@code theme.contactSeparatorStyle()}
*/
public static void leftAligned(SectionBuilder host, CvIdentity identity,
public static void leftAligned(SectionBuilder host, PartyIdentity identity,
BrandTheme theme,
DocumentTextStyle bodyStyleOverride,
DocumentTextStyle linkStyleOverride,
Expand All @@ -151,7 +148,7 @@ public static void leftAligned(SectionBuilder host, CvIdentity identity,
* <li><strong>Row 2</strong> — email {@code |} link₁ {@code |} link₂ … (all clickable)</li>
* </ul>
*
* <p>Email and every {@link CvLink} are rendered as proper PDF
* <p>Email and every {@link Link} are rendered as proper PDF
* hyperlinks (mailto: for the email, the link's URL for each
* label) — not just styled text.</p>
*
Expand All @@ -168,7 +165,7 @@ public static void leftAligned(SectionBuilder host, CvIdentity identity,
* separator; {@code null} →
* {@code theme.contactSeparatorStyle()}
*/
public static void twoRowRightAligned(SectionBuilder host, CvIdentity identity,
public static void twoRowRightAligned(SectionBuilder host, PartyIdentity identity,
BrandTheme theme,
DocumentTextStyle bodyStyleOverride,
DocumentTextStyle linkStyleOverride,
Expand All @@ -180,7 +177,7 @@ public static void twoRowRightAligned(SectionBuilder host, CvIdentity identity,
DocumentTextStyle separatorStyle = separatorStyleOverride != null
? separatorStyleOverride : theme.contactSeparatorStyle();

CvContact c = identity.contact();
Contact c = identity.contact();
host.spacing(0).padding(theme.spacing().contactPadding())
// Row 1 — address + phone.
.addParagraph(p -> p
Expand All @@ -200,7 +197,7 @@ public static void twoRowRightAligned(SectionBuilder host, CvIdentity identity,
.rich(rich -> {
rich.with(c.email(), linkStyle,
new DocumentLinkOptions("mailto:" + c.email()));
for (CvLink l : identity.links()) {
for (Link l : identity.links()) {
rich.style(" | ", separatorStyle);
rich.with(l.label(), linkStyle,
new DocumentLinkOptions(l.url()));
Expand All @@ -218,7 +215,7 @@ public static void twoRowRightAligned(SectionBuilder host, CvIdentity identity,
* @param theme the active theme supplying palette, typography, and spacing
*/
public static void rightAlignedStacked(SectionBuilder host,
CvIdentity identity,
PartyIdentity identity,
BrandTheme theme) {
rightAlignedStacked(host, identity, theme, null, null);
}
Expand All @@ -236,7 +233,7 @@ public static void rightAlignedStacked(SectionBuilder host,
* → resolved body style
*/
public static void rightAlignedStacked(SectionBuilder host,
CvIdentity identity,
PartyIdentity identity,
BrandTheme theme,
DocumentTextStyle bodyStyleOverride,
DocumentTextStyle linkStyleOverride) {
Expand Down Expand Up @@ -274,7 +271,7 @@ public static void rightAlignedStacked(SectionBuilder host,
* @param alignment horizontal text alignment for the row
* @param order the field order in the rendered line
*/
public static void render(SectionBuilder host, CvIdentity identity, BrandTheme theme,
public static void render(SectionBuilder host, PartyIdentity identity, BrandTheme theme,
TextAlign alignment, Order order) {
List<Part> parts = parts(identity, order);
DocumentTextStyle textStyle = theme.contactStyle();
Expand Down Expand Up @@ -302,7 +299,7 @@ public static void render(SectionBuilder host, CvIdentity identity, BrandTheme t
}));
}

private static void renderStyled(SectionBuilder host, CvIdentity identity,
private static void renderStyled(SectionBuilder host, PartyIdentity identity,
BrandTheme theme, TextAlign alignment,
Order order,
DocumentTextStyle bodyStyleOverride,
Expand Down Expand Up @@ -352,8 +349,8 @@ public enum Order {
ADDRESS_FIRST
}

private static List<Part> parts(CvIdentity identity, Order order) {
CvContact c = identity.contact();
private static List<Part> parts(PartyIdentity identity, Order order) {
Contact c = identity.contact();
List<Part> parts = new ArrayList<>(4 + identity.links().size());
DocumentLinkOptions email = new DocumentLinkOptions("mailto:" + c.email());
switch (order) {
Expand All @@ -368,7 +365,7 @@ private static List<Part> parts(CvIdentity identity, Order order) {
parts.add(new Part(c.email(), email));
}
}
for (CvLink link : identity.links()) {
for (Link link : identity.links()) {
parts.add(new Part(link.label(), new DocumentLinkOptions(link.url())));
}
return parts;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.demcha.compose.document.templates.cv.v2.widgets;
package com.demcha.compose.document.templates.core.identity;

import com.demcha.compose.document.dsl.SectionBuilder;
import com.demcha.compose.document.node.TextAlign;
import com.demcha.compose.document.style.DocumentInsets;
import com.demcha.compose.document.style.DocumentTextStyle;
import com.demcha.compose.document.templates.core.text.TextOrnaments;
import com.demcha.compose.document.templates.cv.v2.data.CvName;
import com.demcha.compose.document.templates.core.theme.BrandTheme;

/**
Expand Down Expand Up @@ -55,7 +54,7 @@ private Headline() {
* @param name name to render
* @param theme the active theme supplying palette, typography, and spacing
*/
public static void spacedCentered(SectionBuilder host, CvName name, BrandTheme theme) {
public static void spacedCentered(SectionBuilder host, String name, BrandTheme theme) {
render(host, name, theme, TextAlign.CENTER, true);
}

Expand All @@ -68,7 +67,7 @@ public static void spacedCentered(SectionBuilder host, CvName name, BrandTheme t
* @param name name to render
* @param theme the active theme supplying palette, typography, and spacing
*/
public static void uppercaseCentered(SectionBuilder host, CvName name,
public static void uppercaseCentered(SectionBuilder host, String name,
BrandTheme theme) {
uppercaseCentered(host, name, theme, null);
}
Expand All @@ -83,10 +82,10 @@ public static void uppercaseCentered(SectionBuilder host, CvName name,
* @param styleOverride explicit style; pass {@code null} to fall
* back to {@code theme.headlineStyle()}
*/
public static void uppercaseCentered(SectionBuilder host, CvName name,
public static void uppercaseCentered(SectionBuilder host, String name,
BrandTheme theme,
DocumentTextStyle styleOverride) {
renderText(host, name.full().toUpperCase(java.util.Locale.ROOT),
renderText(host, name.toUpperCase(java.util.Locale.ROOT),
theme, TextAlign.CENTER, styleOverride);
}

Expand All @@ -99,7 +98,7 @@ public static void uppercaseCentered(SectionBuilder host, CvName name,
* @param name name to render
* @param theme the active theme supplying palette, typography, and spacing
*/
public static void uppercaseLeftAligned(SectionBuilder host, CvName name,
public static void uppercaseLeftAligned(SectionBuilder host, String name,
BrandTheme theme) {
uppercaseLeftAligned(host, name, theme, null);
}
Expand All @@ -114,10 +113,10 @@ public static void uppercaseLeftAligned(SectionBuilder host, CvName name,
* @param styleOverride explicit style; pass {@code null} to fall
* back to {@code theme.headlineStyle()}
*/
public static void uppercaseLeftAligned(SectionBuilder host, CvName name,
public static void uppercaseLeftAligned(SectionBuilder host, String name,
BrandTheme theme,
DocumentTextStyle styleOverride) {
renderText(host, name.full().toUpperCase(java.util.Locale.ROOT),
renderText(host, name.toUpperCase(java.util.Locale.ROOT),
theme, TextAlign.LEFT, styleOverride);
}

Expand All @@ -131,7 +130,7 @@ public static void uppercaseLeftAligned(SectionBuilder host, CvName name,
* @param name name to render
* @param theme the active theme supplying palette, typography, and spacing
*/
public static void rightAligned(SectionBuilder host, CvName name, BrandTheme theme) {
public static void rightAligned(SectionBuilder host, String name, BrandTheme theme) {
rightAligned(host, name, theme, null);
}

Expand All @@ -147,7 +146,7 @@ public static void rightAligned(SectionBuilder host, CvName name, BrandTheme the
* @param styleOverride text style for the headline; pass {@code null}
* to fall back to {@code theme.headlineStyle()}
*/
public static void rightAligned(SectionBuilder host, CvName name, BrandTheme theme,
public static void rightAligned(SectionBuilder host, String name, BrandTheme theme,
DocumentTextStyle styleOverride) {
render(host, name, theme, TextAlign.RIGHT, false, styleOverride);
}
Expand All @@ -165,14 +164,14 @@ public static void rightAligned(SectionBuilder host, CvName name, BrandTheme the
* @param spacedCaps if true, transforms to letter-spaced
* uppercase; if false, renders verbatim
*/
public static void render(SectionBuilder host, CvName name, BrandTheme theme,
public static void render(SectionBuilder host, String name, BrandTheme theme,
TextAlign alignment, boolean spacedCaps) {
render(host, name, theme, alignment, spacedCaps, null);
}

/**
* Lower-level entry with explicit style override. Same shape as
* the 5-arg {@link #render(SectionBuilder, CvName, BrandTheme, TextAlign, boolean)}
* the 5-arg {@link #render(SectionBuilder, String, BrandTheme, TextAlign, boolean)}
* but lets the caller supply a custom {@link DocumentTextStyle}.
*
* @param host host section
Expand All @@ -184,15 +183,15 @@ public static void render(SectionBuilder host, CvName name, BrandTheme theme,
* @param styleOverride explicit style; pass {@code null} to fall
* back to {@code theme.headlineStyle()}
*/
public static void render(SectionBuilder host, CvName name, BrandTheme theme,
public static void render(SectionBuilder host, String name, BrandTheme theme,
TextAlign alignment, boolean spacedCaps,
DocumentTextStyle styleOverride) {
DocumentTextStyle style = styleOverride != null
? styleOverride
: theme.headlineStyle();
String text = spacedCaps
? TextOrnaments.spacedUpper(name.full())
: name.full();
? TextOrnaments.spacedUpper(name)
: name;

renderText(host, text, theme, alignment, style);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.demcha.compose.document.templates.cv.v2.data;
package com.demcha.compose.document.templates.core.identity;

import java.util.Objects;

Expand All @@ -9,12 +9,12 @@
* @param label visible link text (required, non-blank)
* @param url click target (required, non-blank)
*/
public record CvLink(String label, String url) {
public record Link(String label, String url) {

/**
* Validates that both fields are non-null and non-blank.
*/
public CvLink {
public Link {
Objects.requireNonNull(label, "label");
Objects.requireNonNull(url, "url");
if (label.isBlank()) {
Expand All @@ -26,14 +26,14 @@ public record CvLink(String label, String url) {
}

/**
* Convenience factory mirroring {@code CvLink.of("LinkedIn",
* Convenience factory mirroring {@code Link.of("LinkedIn",
* "https://...")} call sites.
*
* @param label visible link text (required, non-blank)
* @param url click target (required, non-blank)
* @return a {@code CvLink} with the given label and target
* @return a {@code Link} with the given label and target
*/
public static CvLink of(String label, String url) {
return new CvLink(label, url);
public static Link of(String label, String url) {
return new Link(label, url);
}
}
Loading
Loading