From 990832b7b75feb0a924a78bcaa830011a23d536f Mon Sep 17 00:00:00 2001 From: Gustavo Quinalha Date: Tue, 16 Jul 2024 18:10:12 -0300 Subject: [PATCH] update --- src/app/app.component.html | 15 ++-- src/app/app.component.ts | 87 +++---------------- .../code-result/code-result.component.html | 16 +++- .../code-result/code-result.component.ts | 20 +++++ .../components/preview/preview.component.html | 22 ++--- src/app/utils/code.js | 52 +++++++++++ src/index.html | 32 ++----- tsconfig.json | 2 + 8 files changed, 131 insertions(+), 115 deletions(-) create mode 100644 src/app/utils/code.js diff --git a/src/app/app.component.html b/src/app/app.component.html index 8a21b49..ccb5c55 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -4,7 +4,7 @@
-
+

Just type the data and generate the meta tags for your website @@ -13,7 +13,7 @@

{{ field.description diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4526287..6fe15d0 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,6 +1,7 @@ -import { Component, signal } from '@angular/core'; +import { Component } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; -import { MetadataService } from 'src/app/metadata.service'; +import { returnCode } from './utils/code'; + @Component({ selector: 'app-root', @@ -8,39 +9,7 @@ import { MetadataService } from 'src/app/metadata.service'; styleUrls: ['./app.component.scss'] }) export class AppComponent { - code? = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - `; - form: FormGroup; - formFields = [ + metatagsList = [ { name: 'charset', type: 'select', description: 'Specifies the character encoding for the HTML document, ensuring proper display of text.', label: 'Charset', options: [ { value: "UTF-8", }, @@ -107,9 +76,13 @@ export class AppComponent { { name: 'site', type: 'text', description: 'The Twitter “@username” the card should be attributed to.', label: 'Site' }, ]; - constructor(private fb: FormBuilder, private metadataService: MetadataService) { + code? = returnCode(null); + + form: FormGroup; + + constructor(private fb: FormBuilder) { this.form = this.fb.group({}); - this.formFields.forEach(field => { + this.metatagsList.forEach(field => { if (field.type === 'select' && field.options) { this.form.addControl(field.name, this.fb.control(field.options[0].value)); } else { @@ -121,42 +94,10 @@ export class AppComponent { } onChanges(): void { - this.form.valueChanges.subscribe(val => { - this.code = ` - - - - ${this.form?.get('title')?.value} - - - - - - - - - - - - - - - - - - - - - - - - - - `}); - } - - onSubmit() { - console.log(this.form.value); + this.form.valueChanges.subscribe(_val => { + console.log('this.form.value', this.form.value); + this.code = returnCode(this.form.value); + }); } setFetchValue(data: any) { diff --git a/src/app/components/code-result/code-result.component.html b/src/app/components/code-result/code-result.component.html index b665d8c..b7eb77c 100644 --- a/src/app/components/code-result/code-result.component.html +++ b/src/app/components/code-result/code-result.component.html @@ -1,3 +1,13 @@ -
-  
-
+
+
+ +
+
+    
+  
+ +
diff --git a/src/app/components/code-result/code-result.component.ts b/src/app/components/code-result/code-result.component.ts index 00792c5..1a96b4e 100644 --- a/src/app/components/code-result/code-result.component.ts +++ b/src/app/components/code-result/code-result.component.ts @@ -7,4 +7,24 @@ import { Component, Input } from '@angular/core'; }) export class CodeResultComponent { @Input() code?: any; + + copy() { + const teste: HTMLElement = document.querySelector("code")!; + const range = document.createRange(); + range.selectNodeContents(teste); + + const selection = window.getSelection(); + if (selection) { + selection.removeAllRanges(); + selection.addRange(range); + } + + try { + const successful = document.execCommand('copy'); + const msg = successful ? 'Texto copiado com sucesso!' : 'Falha ao copiar o texto'; + console.log(msg); + } catch (err) { + console.error('Erro ao copiar o texto: ', err); + } + } } diff --git a/src/app/components/preview/preview.component.html b/src/app/components/preview/preview.component.html index d6f2b6b..32a8465 100644 --- a/src/app/components/preview/preview.component.html +++ b/src/app/components/preview/preview.component.html @@ -2,8 +2,8 @@ class="text-zinc-200 gap-4 md:gap-8 h-full flex flex-col mb-4 md:mb-8 lg:mb-10 pb-4 md:pb-8 lg:pb-10" >
-
Google
-
+
Google
+
{{ content?.title || "Page title" }}
@@ -17,9 +17,9 @@
-
Twitter
-
-
+
Twitter
+
+
-
Facebook
-
-
+
Facebook
+
+
-
Linkedin
-
-
+
Linkedin
+
+
+ + + ${data.title} + + + + + + + + + + + + + + + + + + + + + + + + + + `; +} diff --git a/src/index.html b/src/index.html index 4f011a8..cc860a2 100644 --- a/src/index.html +++ b/src/index.html @@ -20,42 +20,28 @@ SeoTopper - SEO Generator - + + + + + - - - + + - - - - + + diff --git a/tsconfig.json b/tsconfig.json index c2b1045..72c126b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,8 @@ "moduleResolution": "bundler", "compileOnSave": false, "compilerOptions": { + "allowJs": true, + "esModuleInterop": true, "baseUrl": "./", "outDir": "./dist/out-tsc", "forceConsistentCasingInFileNames": true,