Skip to content

Commit 5b12b9d

Browse files
abdullahtilal26abdullahtilal26
authored andcommitted
feat: add Noibu Help codes component in Makeswift
1 parent b0da775 commit 5b12b9d

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

core/lib/makeswift/components.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import './components/site-header/register';
1414
import './components/site-theme/register';
1515
import './components/slideshow/register';
1616
import './components/sticky-sidebar/register';
17+
import './components/noibu/register';
1718

1819
import { MakeswiftComponentType } from '@makeswift/runtime';
1920

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
interface NoibuHelpCodeProps {
2+
style?: string;
3+
}
4+
5+
interface NoibuRequestHelpCodeButtonProps {
6+
text?: string;
7+
style?: string;
8+
}
9+
10+
interface NoibuRequestHelpCodeLabelProps {
11+
style?: string;
12+
}
13+
14+
function parseInlineStyle(style?: string): Record<string, string> {
15+
const parsed: Record<string, string> = {};
16+
17+
if (style) {
18+
style.split(';').forEach((rule) => {
19+
const [prop, value] = rule.split(':');
20+
if (prop && value && !prop.trim().includes('-')) {
21+
parsed[prop.trim()] = value.trim();
22+
}
23+
});
24+
}
25+
26+
return parsed;
27+
}
28+
29+
export function NoibuAutomaticHelpCode({ style }: NoibuHelpCodeProps) {
30+
return (
31+
<div id="help-code-field" style={{ ...parseInlineStyle(style) }}>
32+
&nbsp;
33+
</div>
34+
);
35+
}
36+
37+
export function NoibuRequestHelpCodeButton({ text, style }: NoibuRequestHelpCodeButtonProps) {
38+
return (
39+
<button id="request-help-code" style={{ ...parseInlineStyle(style) }}>
40+
{text || 'Request Help Code'}
41+
</button>
42+
);
43+
}
44+
45+
export function NoibuRequestHelpCodeLabel({ style }: NoibuRequestHelpCodeLabelProps) {
46+
return (
47+
<div id="help-code-result" style={{ ...parseInlineStyle(style) }}>
48+
&nbsp;
49+
</div>
50+
);
51+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { TextInput } from '@makeswift/runtime/controls';
2+
import { runtime } from '~/lib/makeswift/runtime';
3+
import {
4+
NoibuAutomaticHelpCode,
5+
NoibuRequestHelpCodeButton,
6+
NoibuRequestHelpCodeLabel,
7+
} from './client';
8+
9+
runtime.registerComponent(NoibuAutomaticHelpCode, {
10+
type: 'Noibu - Automatic Help Code',
11+
label: 'Noibu - Automatic Help Code',
12+
props: {
13+
style: TextInput({ label: 'Custom style (inline CSS)', defaultValue: '' }),
14+
},
15+
});
16+
17+
runtime.registerComponent(NoibuRequestHelpCodeButton, {
18+
type: 'Noibu - Request Help Code Button',
19+
label: 'Noibu - Request Help Code Button',
20+
props: {
21+
text: TextInput({ label: 'Button text', defaultValue: 'Request Help Code' }),
22+
style: TextInput({ label: 'Custom style (inline CSS)', defaultValue: '' }),
23+
},
24+
});
25+
26+
runtime.registerComponent(NoibuRequestHelpCodeLabel, {
27+
type: 'Noibu - Request Help Code Label',
28+
label: 'Noibu - Request Help Code Label',
29+
props: {
30+
style: TextInput({ label: 'Custom style (inline CSS)', defaultValue: '' }),
31+
},
32+
});

0 commit comments

Comments
 (0)