-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
1 parent
e87e1e5
commit 106f76e
Showing
16 changed files
with
349 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# @hyperbook/element-tiles | ||
|
||
## Installation | ||
|
||
```sh | ||
yarn add @hyperbook/element-tiles | ||
# or | ||
npm i @hyperbook/element-tiles | ||
``` |
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,51 @@ | ||
{ | ||
"name": "@hyperbook/element-tiles", | ||
"version": "0.0.0", | ||
"author": "Mike Barkmin", | ||
"homepage": "https://github.com/openpatch/hyperbook#readme", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"sideEffects": false, | ||
"exports": { | ||
".": "./dist/index.js", | ||
"./index.css": "./dist/index.css" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/openpatch/hyperbook.git", | ||
"directory": "packages/element-tiles" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/openpatch/hyperbook/issues" | ||
}, | ||
"scripts": { | ||
"version": "pnpm build", | ||
"lint": "tsc --noEmit", | ||
"build": "rimraf dist && pnpm build:pkg && pnpm build:types", | ||
"build:pkg": "node ../../scripts/build.mjs", | ||
"build:types": "tsc --project tsconfig.build.json --declaration --emitDeclarationOnly" | ||
}, | ||
"dependencies": { | ||
"@hyperbook/provider": "workspace:*", | ||
"@hyperbook/store": "workspace:*" | ||
}, | ||
"peerDependencies": { | ||
"react": "18.x", | ||
"react-dom": "18.x", | ||
"react-redux": "8.x" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "18.0.15", | ||
"@types/react-dom": "18.0.6", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"vitest": "^0.26.3" | ||
} | ||
} |
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,91 @@ | ||
.hyperbook .tiles { | ||
display: grid; | ||
column-gap: 0.75rem; | ||
row-gap: 0.75rem; | ||
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr; | ||
margin: 0; | ||
padding: 0; | ||
position: relative; | ||
width: 100%; | ||
list-style-type: none; | ||
} | ||
|
||
.element-tiles .tile.S { | ||
grid-column-start: span 2; | ||
} | ||
|
||
.element-tiles .tile.M { | ||
grid-column-start: span 3; | ||
} | ||
|
||
.element-tiles .tile.L { | ||
grid-column-start: span 4; | ||
} | ||
|
||
@media screen and (max-width: 900px) { | ||
.hyperbook .tiles { | ||
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr; | ||
} | ||
|
||
.element-tiles .tile.S { | ||
grid-column-start: span 4; | ||
} | ||
|
||
.element-tiles .tile.M { | ||
grid-column-start: span 6; | ||
} | ||
|
||
.element-tiles .tile.L { | ||
grid-column-start: span 8; | ||
} | ||
} | ||
|
||
@media screen and (max-width: 600px) { | ||
.hyperbook .tiles { | ||
grid-template-columns: 1fr 1fr; | ||
} | ||
|
||
.element-tiles .tile.S { | ||
grid-column-start: span 1; | ||
} | ||
|
||
.element-tiles .tile.M { | ||
grid-column-start: span 1; | ||
} | ||
|
||
.element-tiles .tile.L { | ||
grid-column-start: span 1; | ||
} | ||
} | ||
|
||
.element-tiles .tile { | ||
line-height: 1.2em; | ||
min-height: 6rem; | ||
background: var(--color-nav); | ||
transition: all 300ms; | ||
padding: 8px; | ||
position: relative; | ||
border-radius: 8px; | ||
} | ||
|
||
.element-tiles .tile.link:hover { | ||
background: var(--color-brand); | ||
color: var(--color-brand-text); | ||
} | ||
|
||
.element-tiles .tile.link:hover a { | ||
color: var(--color-brand-text); | ||
height: 100%; | ||
display: block; | ||
} | ||
|
||
.element-tiles .tile.link a { | ||
text-decoration: none; | ||
} | ||
|
||
.element-tiles .tile-icon { | ||
position: absolute; | ||
width: 3rem; | ||
bottom: 0.5rem; | ||
right: 0.5rem; | ||
} |
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,54 @@ | ||
import { FC, Fragment, ReactNode } from "react"; | ||
import { createSlice } from "@hyperbook/store"; | ||
import "./index.css"; | ||
|
||
type DirectiveTilesProps = { | ||
children?: ReactNode; | ||
}; | ||
|
||
const DirectiveTiles: FC<DirectiveTilesProps> = ({ children }) => { | ||
return ( | ||
<div className="hyperbook element-tiles"> | ||
<ul className="tiles">{children}</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
type DirectiveTileProps = { | ||
size?: "S" | "M" | "L"; | ||
title?: string; | ||
description?: string; | ||
href?: string; | ||
icon?: string; | ||
}; | ||
|
||
const DirectiveTile: FC<DirectiveTileProps> = ({ | ||
size = "M", | ||
title, | ||
href, | ||
icon, | ||
}) => { | ||
return ( | ||
<li className={`tile ${size} ${href ? "link" : ""}`}> | ||
<a className="tile-title" href={href}> | ||
{title} | ||
</a> | ||
{icon && <img className="tile-icon" src={icon} />} | ||
</li> | ||
); | ||
}; | ||
|
||
type ElementTilesState = {}; | ||
|
||
const initialState: ElementTilesState = {}; | ||
|
||
const sliceTiles = createSlice({ | ||
name: "element.tiles", | ||
initialState, | ||
reducers: {}, | ||
}); | ||
|
||
export default { | ||
directives: { tiles: DirectiveTiles, tile: DirectiveTile }, | ||
slice: sliceTiles, | ||
}; |
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,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["src", "../../types"], | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"declarationDir": "dist" | ||
} | ||
} |
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,4 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"include": ["src", "../../types", "tests"] | ||
} |
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,3 @@ | ||
import { defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,39 @@ | ||
--- | ||
name: Kacheln | ||
lang: de | ||
--- | ||
|
||
# Kacheln | ||
|
||
Kacheln sind eine schöne visuelle Möglichkeit für Startseiten oder | ||
Übersichtsseiten, welche deinen Benutzern helfen sollen sich zurechtzufinden. | ||
|
||
```md | ||
:::tiles | ||
|
||
::tile{title="Hallo"} | ||
|
||
::tile{title="Eine Kachel mit einem Link" href="openpatch.org"} | ||
|
||
::tile{title="Eine große Kachel" size="L"} | ||
|
||
::tile{title="Eine kleine Kachel" size="S"} | ||
|
||
::tile{title="Eine Kachel mit einem Icon" icon="https://www.inf-schule.de/assets/img/icons/icon_algorithmen.png"} | ||
|
||
::: | ||
``` | ||
|
||
:::tiles | ||
|
||
::tile{title="Hallo"} | ||
|
||
::tile{title="Eine Kachel mit einem Link" href="openpatch.org"} | ||
|
||
::tile{title="Eine große Kachel" size="L"} | ||
|
||
::tile{title="Eine kleine Kachel" size="S"} | ||
|
||
::tile{title="Eine Kachel mit einem Icon" icon="https://www.inf-schule.de/assets/img/icons/icon_algorithmen.png"} | ||
|
||
::: |
Oops, something went wrong.