Skip to content

Commit

Permalink
feat: ✨ add support for header block
Browse files Browse the repository at this point in the history
  • Loading branch information
themashcodee committed Jun 28, 2024
1 parent f597b66 commit c4540ff
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"repository": "https://github.com/themashcodee/slack-blocks-to-jsx.git",
"license": "MIT",
"version": "0.3.1",
"version": "0.3.2",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Each Slack block type has a corresponding component:
- `Context` (✅ supported)
- `Actions` (🟨 partially supported)
- `File` (❌ not supported yet)
- `Header` (❌ not supported yet)
- `Header` (supported)
- `Input` (🟨 partially supported)
- `RichText` (✅ supported)
- `Video` (✅ supported)
Expand Down
11 changes: 9 additions & 2 deletions src/components/blocks/header.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { HeaderBlock } from "../../types";
import { TextObject } from "../composition_objects";

type HeaderProps = {
data: HeaderBlock;
};

export const Header = (props: HeaderProps) => {
const { type } = props.data;
const { text, block_id } = props.data;

return null;
return (
<div id={block_id} className="mt-1 slack_blocks_to_jsx__header">
<h3 className="text-header font-bold slack_blocks_to_jsx__header_heading">
<TextObject data={text} />
</h3>
</div>
);
};
2 changes: 2 additions & 0 deletions src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ export const getBlockComponent = (block: Block): ReactNode => {
if (block.type === "context") return <Context data={block} />;
if (block.type === "actions") return <Actions data={block} />;
if (block.type === "file") return <File data={block} />;
// ✅ DONE
if (block.type === "header") return <Header data={block} />;
// ✅ PARTIALLY DONE
if (block.type === "input") return <Input data={block} />;
// ✅ DONE
if (block.type === "video") return <Video data={block} />;
// ✅ DONE
if (block.type === "rich_text") return <RichText data={block} />;
Expand Down
1 change: 1 addition & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = {
fontSize: {
"small": ["13px", "1.38461538"],
"base": ["15px", "1.46668"],
"header": ["18px", "1.33334"],
},
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
Expand Down

0 comments on commit c4540ff

Please sign in to comment.