Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dennispost committed Oct 23, 2024
1 parent e1c42a0 commit 523f8ce
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/utils/outputs/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const downloadTheme = async (
const iOSDataFolder: string = `${iOSThemeFolder}/data`;
zip.file(
`${iOSFolder}/README.md`,
generateSwiftUIReadmeFile(iOSFileName),
generateSwiftUIReadmeFile(),
);
zip.file(
`${iOSFolder}/${designSystemName}ColorScheme.swift`,
Expand Down
59 changes: 38 additions & 21 deletions src/utils/outputs/swiftui/readme.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,53 @@
export const generateSwiftUIReadmeFile = (fileName: string): string => {
export const generateSwiftUIReadmeFile = (): string => {
return `# How to use the theme
1. Move the \`theme\` directory into your project
2. Replace the string \`replace.\` inside the \`theme\` directory with your package name for example: \`com.example.myapplication.\`
3. Add your theme to the MainActivity:
3. Add your theme to your \`ContentView\`:
\`\`\`\` kotlin
import com.example.myapplication.theme.${fileName}
...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
${fileName} {
//... your content
}
import SwiftUI
@main
struct YourApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.dsTheme()
}
}
}
\`\`\`\`
Use the tokens like this:
\`\`\`\` kotlin
Text(
text = "Headline",
style = DBTheme.typography.h1,
color = DBTheme.colors.neutral.onBgBasicEmphasis100,
modifier = Modifier.padding(DBTheme.dimensions.spacing.fixedMd)
)
\`\`\`\` swift
struct ContentView: View {
@Environment(\\.theme) var theme
@State var scheme: DSColorVariant?
var body: some View {
Text("Headline")
.font(theme.fonts.h1.font)
.foregroundColor(theme.activeColor.onBgBasicEmphasis80Default)
.padding(theme.dimensions.spacing.responsiveXs)
}
}
\`\`\`\`
## Fonts
To use another theme, export it and copy the \`theme/<theme name>\` directory to your project. Set it like this:
[Download](https://marketingportal.extranet.deutschebahn.com/marketingportal/Design-Anwendungen/db-ux-design-system/version-2/foundation/Typografie) fonts and use the \`.ttf\` files.
You might rename it based on the names in \`~/theme/data/Fonts.kt\` and move the \`.ttf\` files into \`~/res/font\` folder.
\`\`\`swift
// Code from step 3
@main
struct YourApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.dsTheme(<theme name>Theme())
}
}
}
\`\`\`
`;
};
1 change: 0 additions & 1 deletion src/utils/outputs/swiftui/typography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct DSFont {
self.publicName = publicName
do {
try registerFont(fontName: name)
print("Registered Font \\(name)")
} catch {
let reason = error.localizedDescription
fatalError("Failed to register font: \\(reason)")
Expand Down

0 comments on commit 523f8ce

Please sign in to comment.