Skip to content

Commit 6551b25

Browse files
feat: implement angular npm package use case in public template
1 parent 3fc41f4 commit 6551b25

File tree

1 file changed

+134
-5
lines changed

1 file changed

+134
-5
lines changed

apps/OpenSign/src/components/pdf/EmbedTab.js

Lines changed: 134 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ function EmbedTab(props) {
88
const { t } = useTranslation();
99
const tabName = [
1010
{ title: "React/Next.js", icon: "fa-brands fa-react", color: "#61dafb" },
11+
{ title: "JavaScript", icon: "fa-brands fa-js", color: "#ffd43b" },
1112
{ title: "Angular", icon: "fa-brands fa-angular", color: "#ff5733" }
1213
];
1314
const [activeTab, setActiveTab] = useState(0);
1415
// State to track if the code has been copied
1516
const [isCopied, setIsCopied] = useState(false);
16-
const codeData = [
17+
const reactCode = [
1718
{
1819
id: 0,
1920
title: "Installation",
@@ -44,6 +45,51 @@ export function App() {
4445
}
4546
];
4647

48+
const angularCode = [
49+
{
50+
id: 0,
51+
title: "Installation",
52+
codeString: `
53+
npm install opensign-angular`
54+
},
55+
{
56+
id: 1,
57+
title: "Usage",
58+
codeString: `
59+
import { Component } from '@angular/core';
60+
import {OpensignComponent} from "opensign-angular"
61+
62+
@Component({
63+
selector:'app-root',
64+
standalone: true,
65+
imports: [OpensignComponent],
66+
template: '<opensign templateId={"${props.templateId}"}
67+
(onLoad)="handleLoad()"
68+
(onLoadError)="handleError($event)"
69+
></opensign>',
70+
})
71+
export class AppComponent{
72+
handleLoad() {
73+
console.log("success");
74+
}
75+
handleError(error: string) {
76+
console.log(error);
77+
}
78+
79+
}
80+
81+
82+
`
83+
}
84+
];
85+
const jsCodeString = `
86+
<script
87+
src= "https://app.opensignlabs.com/static/js/public-template.bundle.js"
88+
id="opensign-script"
89+
templateId=${props.templateId}
90+
></script>
91+
`;
92+
4793
const handleCopy = (code, ind) => {
4894
copytoData(code);
4995
setIsCopied({ ...isCopied, [ind]: true });
@@ -75,7 +121,7 @@ export function App() {
75121
<div>
76122
{activeTab === 0 ? (
77123
<div className="mt-4">
78-
{codeData.map((data, ind) => {
124+
{reactCode.map((data, ind) => {
79125
return (
80126
<div key={ind}>
81127
<p className="font-medium text-[18px]">
@@ -133,10 +179,93 @@ export function App() {
133179
{t("public-template-mssg-5")}
134180
</p>
135181
</div>
182+
) : activeTab === 1 ? (
183+
<div className="mt-4">
184+
<div>
185+
{/* <p className="font-medium text-[18px]">{t(`${data.title}`)}</p> */}
186+
187+
<div className="relative p-1">
188+
<div
189+
onClick={() => handleCopy(jsCodeString, 0)}
190+
className="absolute top-[20px] right-[20px] cursor-pointer"
191+
>
192+
<i className="fa-light fa-copy text-white mr-[2px]" />
193+
<span className=" text-white">
194+
{isCopied[0] ? t("copied-code") : t("copy-code")}
195+
</span>
196+
</div>
197+
<SyntaxHighlighter
198+
customStyle={{
199+
borderRadius: "15px"
200+
}}
201+
language="javascript"
202+
style={tomorrow}
203+
>
204+
{jsCodeString}
205+
</SyntaxHighlighter>
206+
</div>
207+
</div>
208+
</div>
136209
) : (
137-
activeTab === 1 && (
138-
<div className="mt-3">
139-
<p>Feature comming soon</p>
210+
activeTab === 2 && (
211+
<div className="mt-4">
212+
{angularCode.map((data, ind) => {
213+
return (
214+
<div key={ind}>
215+
<p className="font-medium text-[18px]">
216+
{t(`${data.title}`)}
217+
</p>
218+
{ind === 0 && (
219+
<p className="text-[13px] mt-2">
220+
{t("public-template-mssg-1")}
221+
</p>
222+
)}
223+
<div className="relative p-1">
224+
<div
225+
onClick={() => handleCopy(data.codeString, ind)}
226+
className="absolute top-[20px] right-[20px] cursor-pointer"
227+
>
228+
<i className="fa-light fa-copy text-white mr-[2px]" />
229+
<span className=" text-white">
230+
{isCopied[ind] ? t("copied-code") : t("copy-code")}
231+
</span>
232+
</div>
233+
<SyntaxHighlighter
234+
customStyle={{
235+
borderRadius: "15px"
236+
}}
237+
language="javascript"
238+
style={tomorrow}
239+
>
240+
{data.codeString}
241+
</SyntaxHighlighter>
242+
</div>
243+
{ind === 0 && (
244+
<p className="text-[13px] mb-3">
245+
{t("public-template-mssg-2")}
246+
</p>
247+
)}
248+
</div>
249+
);
250+
})}
251+
252+
<p className="font-medium text-[15px]">
253+
{t("public-template-mssg-3")}
254+
</p>
255+
<p className="my-[6px]">
256+
{" "}
257+
{t("public-template-mssg-4")}
258+
<a
259+
href="https://www.npmjs.com/package/opensignme-angular"
260+
target="_blank"
261+
rel="noreferrer"
262+
className="cursor-pointer text-blue-700 "
263+
>
264+
{" "}
265+
OpenSign Angular package{" "}
266+
</a>
267+
{t("public-template-mssg-5")}
268+
</p>
140269
</div>
141270
)
142271
)}

0 commit comments

Comments
 (0)