Skip to content

Commit

Permalink
feat(nx-dev): add markdoc title card component
Browse files Browse the repository at this point in the history
  • Loading branch information
bcabanes committed Apr 4, 2023
1 parent 807884c commit 0407252
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
13 changes: 12 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Your content goes here.

#### Cards

Cards allow to show content in a grid system with a title, a description, a type and an url (internal/external).
Cards allow showing content in a grid system with a title, a description, a type and an url (internal/external).

```markdown
{% cards %}
Expand All @@ -46,6 +46,17 @@ Cards allow to show content in a grid system with a title, a description, a type
{% /cards %}
```

Title cards allow to only show a title in a card with a title and an url.

```markdown
{% cards cols="4" %}
{% title-card title="string" href="string" /%}
{% title-card title="string" href="string" /%}
{% title-card title="string" href="string" /%}
{% title-card title="string" href="string" /%}
{% /cards %}
```

#### Code

You can add specific languages and a filename on the code snippet displayed.
Expand Down
6 changes: 4 additions & 2 deletions nx-dev/ui-markdoc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { CustomLink } from './lib/nodes/link.component';
import { link } from './lib/nodes/link.schema';
import { Callout } from './lib/tags/callout.component';
import { callout } from './lib/tags/callout.schema';
import { Card, Cards } from './lib/tags/cards.component';
import { card, cards } from './lib/tags/cards.schema';
import { Card, Cards, TitleCard } from './lib/tags/cards.component';
import { card, cards, titleCard } from './lib/tags/cards.schema';
import { GithubRepository } from './lib/tags/github-repository.component';
import { githubRepository } from './lib/tags/github-repository.schema';
import { Graph } from './lib/tags/graph.component';
Expand Down Expand Up @@ -62,6 +62,7 @@ export const getMarkdocCustomConfig = (
'side-by-side': sideBySide,
tab,
tabs,
'title-card': titleCard,
youtube,
},
},
Expand All @@ -82,6 +83,7 @@ export const getMarkdocCustomConfig = (
SideBySide,
Tab,
Tabs,
TitleCard,
YouTube,
},
});
Expand Down
14 changes: 14 additions & 0 deletions nx-dev/ui-markdoc/src/lib/tags/cards.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,17 @@ export function Card({
</div>
);
}

export function TitleCard({ title, url }: { title: string; url: string }) {
return (
<a
key={title}
href={'blahblah'}
className="relative col-span-1 flex items-center rounded-md border border-slate-200 bg-slate-50/40 p-4 text-left text-lg font-semibold shadow-sm transition focus-within:ring-2 focus-within:ring-blue-500 focus-within:ring-offset-2 hover:bg-slate-50 dark:border-slate-800/40 dark:bg-slate-800/60 dark:hover:bg-slate-800 lg:justify-center lg:text-center"
style={{ textDecorationLine: 'none' }}
>
<span className="absolute inset-0" />
{title}
</a>
);
}
13 changes: 13 additions & 0 deletions nx-dev/ui-markdoc/src/lib/tags/cards.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@ export const card: Schema = {
},
},
};
export const titleCard: Schema = {
render: 'TitleCard',
attributes: {
title: {
type: 'String',
required: true,
},
url: {
type: 'String',
required: true,
},
},
};

0 comments on commit 0407252

Please sign in to comment.