Skip to content

Commit

Permalink
feat(website): Add FeatureCards component and enhance Home documentat…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
Ayfri committed Jan 8, 2025
1 parent c4a1089 commit b872721
Show file tree
Hide file tree
Showing 2 changed files with 226 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
package io.github.ayfri.kore.website.components.doc

import androidx.compose.runtime.Composable
import com.varabyte.kobweb.compose.css.translateY
import com.varabyte.kobweb.silk.components.icons.mdi.MdiBook
import com.varabyte.kobweb.silk.components.icons.mdi.MdiDataObject
import com.varabyte.kobweb.silk.components.icons.mdi.MdiFunctions
import com.varabyte.kobweb.silk.components.icons.mdi.MdiSettings
import io.github.ayfri.kore.website.GlobalStyle
import io.github.ayfri.kore.website.utils.marginY
import io.github.ayfri.kore.website.utils.transition
import org.jetbrains.compose.web.css.*
import org.jetbrains.compose.web.dom.A
import org.jetbrains.compose.web.dom.Div
import org.jetbrains.compose.web.dom.H3
import org.jetbrains.compose.web.dom.Text

object FeatureStyle : StyleSheet() {
val grid by style {
display(DisplayStyle.Grid)
gridTemplateColumns("repeat(2, 1fr)")
gap(1.5.cssRem)
margin(1.5.cssRem, 0.cssRem)
}

val card by style {
backgroundColor(GlobalStyle.secondaryBackgroundColor)
borderRadius(8.px)
padding(2.cssRem, 1.5.cssRem)
display(DisplayStyle.Grid)
gridTemplateColumns("64px 1fr")
gap(2.cssRem)
transition(0.2.s, "translate")

self + hover style {
translateY((-4).px)
}
}

val icon by style {
display(DisplayStyle.Flex)
alignItems(AlignItems.Center)
justifyContent(JustifyContent.Center)
color(Color.white)

"span" style {
fontSize(48.px)
opacity(0.8)
}
}

val content by style {
display(DisplayStyle.Flex)
flexDirection(FlexDirection.Column)
gap(1.cssRem)

"h3" style {
marginY(0.cssRem)
}
}

val featureLink by style {
color(GlobalStyle.textColor)
textDecoration("none")
cursor("pointer")
transition(0.2.s, "color")

self + hover style {
color(GlobalStyle.linkColor)
}
}

val linkList by style {
display(DisplayStyle.Flex)
flexDirection(FlexDirection.Column)
}
}

@Composable
private fun FeatureIcon(content: @Composable () -> Unit) {
Div({
classes(FeatureStyle.icon)
}) {
content()
}
}

@Composable
private fun FeatureCard(
title: String,
icon: @Composable () -> Unit,
content: @Composable () -> Unit,
) {
Div({
classes(FeatureStyle.card)
}) {
FeatureIcon(icon)
Div({
classes(FeatureStyle.content)
}) {
H3 { Text(title) }
content()
}
}
}

@Composable
private fun FeatureLink(href: String, text: String) {
A(href = href, {
classes(FeatureStyle.featureLink)
}) {
Text(text)
}
}

@Composable
fun FeatureGrid() {
Style(FeatureStyle)

Div({
classes(FeatureStyle.grid)
}) {
FeatureCard(
title = "Getting Started",
icon = { MdiBook() }
) {
Div({
classes(FeatureStyle.linkList)
}) {
FeatureLink("/docs/configuration", "Project Configuration")
FeatureLink("/docs/creating-a-datapack", "Your First Datapack")
}
}

FeatureCard(
title = "Commands & Functions",
icon = { MdiFunctions() }
) {
Div({
classes(FeatureStyle.linkList)
}) {
FeatureLink("/docs/functions", "Functions")
FeatureLink("/docs/functions/macros", "Macro System")
FeatureLink("/docs/scoreboards", "Scoreboards")
}
}

FeatureCard(
title = "Data-driven Features",
icon = { MdiDataObject() }
) {
Div({
classes(FeatureStyle.linkList)
}) {
FeatureLink("/docs/advancements", "Advancements")
FeatureLink("/docs/recipes", "Recipes")
}
}

FeatureCard(
title = "Miscellaneous",
icon = { MdiSettings() }
) {
Div({
classes(FeatureStyle.linkList)
}) {
FeatureLink("/docs/components", "Components")
FeatureLink("/docs/chat-components", "Chat Components")
FeatureLink("/docs/helpers/display-entities", "Display Entities")
}
}
}
}
55 changes: 53 additions & 2 deletions website/src/jsMain/resources/markdown/doc/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ nav-title: Home
description: Welcome to the Kore wiki!
keywords: minecraft, datapack, kore, guide
date-created: 2024-04-06
date-modified: 2024-04-06
date-modified: 2025-01-08
routeOverride: /docs/home
position: 0
---
Expand All @@ -15,4 +15,55 @@ position: 0
**Welcome to the Kore wiki!**

Kore is a Kotlin library for creating Minecraft datapacks. It provides a type-safe and concise way to generate Minecraft datapacks using
Kotlin DSL.
Kotlin DSL. The library is compatible with Minecraft Java 1.20 and later versions.

## Getting Started

The easiest way to start with Kore is to use the [Kore Template](https://github.com/Ayfri/Kore-Template). This template repository provides a ready-to-use project structure with all the necessary configurations.

### Prerequisites

- Java Development Kit (JDK) version 21 or higher

### Features

Kore comes with a rich set of features:

- Generate datapacks as files, zips, or jar files for mod-loaders
- Create functions with a clean Kotlin DSL
- Support for all Minecraft commands with their subcommands and syntaxes
- Generate all JSON-based features (Advancements, Loot Tables, Recipes, etc.)
- Work with Selectors, NBT tags, and Chat components
- Access lists for all Minecraft registries (Blocks, Items, Entities, Advancements)
- Use Colors, Vectors, Rotations with common operations
- Support for Macros
- Manage inventories and schedulers
- Merge datapacks, even with existing zips
- Manage scoreboard displays
- Built-in debugging system
- Common NBT tags generation
- Experimental OOP module

### Explore Kore

{{{ .components.doc.FeatureGrid }}}

### Quick Example

```kotlin
fun main() {
val datapack = dataPack("test") {
function("display_text") {
tellraw(allPlayers(), textComponent("Hello World!"))
}

pack {
description = textComponent("My First ", Color.GOLD) + text("Kore", Color.AQUA) { bold = true }
}
}

datapack.generateZip()
}
```

For more detailed information, examples, and guides, explore our documentation sections.

0 comments on commit b872721

Please sign in to comment.