generated from Tinkoff/angular-open-source-starter
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: splincode <>
- Loading branch information
Showing
33 changed files
with
871 additions
and
64 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 23 additions & 48 deletions
71
apps/demo/src/app/pages/changelog/editor-changelog.style.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,35 @@ | ||
markdown { | ||
.changelog { | ||
max-width: 58.25rem; | ||
|
||
& > :nth-child(1), | ||
& > :nth-child(2) { | ||
display: none; | ||
} | ||
|
||
> * { | ||
margin-left: 1.25rem; | ||
} | ||
|
||
& h2 { | ||
font-size: 2em; | ||
padding-bottom: 0.5em; | ||
margin-left: 0; | ||
border-bottom: 1px solid var(--tui-base-03); | ||
} | ||
|
||
& h3 { | ||
text-transform: uppercase; | ||
font-weight: normal; | ||
font-size: 1.5rem; | ||
margin: 1rem 0; | ||
} | ||
|
||
& h3:not([id^='feat']):not([id^='bug']):not([id^='deprecations']) { | ||
font-size: 1.75rem; | ||
padding-bottom: 0.5em; | ||
margin: 2rem 0 0 0; | ||
border-bottom: 1px solid var(--tui-base-03); | ||
} | ||
|
||
& h3[id^='breaking'] { | ||
> *:not(h2) { | ||
margin-left: 1.25rem; | ||
color: var(--tui-error-fill); | ||
} | ||
|
||
& code { | ||
color: #d45d8c; | ||
} | ||
|
||
& h3[id^='feat']:before { | ||
content: '🚀'; | ||
} | ||
a { | ||
text-decoration: none; | ||
color: var(--tui-link); | ||
|
||
& h3[id^='bug']:before { | ||
content: '🐞'; | ||
&:hover, | ||
&:active { | ||
color: var(--tui-link-hover); | ||
} | ||
} | ||
|
||
& h3[id^='deprecations']:before { | ||
content: '⚠️'; | ||
li { | ||
position: relative; | ||
padding-left: 1.5rem; | ||
word-wrap: break-word; | ||
margin-top: 0.75rem; | ||
} | ||
|
||
& h3[id^='feat']:before, | ||
& h3[id^='bug']:before, | ||
& h3[id^='deprecations']:before { | ||
margin-right: 0.5rem; | ||
li:before { | ||
content: ''; | ||
position: absolute; | ||
left: 0; | ||
top: 0.5rem; | ||
width: 0.5rem; | ||
height: 0.5rem; | ||
border-radius: 100%; | ||
background-color: var(--tui-primary); | ||
} | ||
} |
5 changes: 4 additions & 1 deletion
5
apps/demo/src/app/pages/changelog/editor-changelog.template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
<tui-doc-page header="Changelog"> | ||
<markdown [data]="(changelog$ | async) || ''"></markdown> | ||
<div | ||
class="changelog" | ||
[innerHTML]="changelog$ | async" | ||
></div> | ||
</tui-doc-page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './ts-file.parser'; | ||
export * from './ts-file-component.parser'; | ||
export * from './ts-file-module.parser'; |
24 changes: 24 additions & 0 deletions
24
apps/demo/src/app/pages/stackblitz/classes/ts-file-component.parser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {TsFileParser} from './ts-file.parser'; | ||
|
||
export class TsFileComponentParser extends TsFileParser { | ||
set selector(newSelector: string) { | ||
this.rawFileContent = this.rawFileContent.replace( | ||
/(selector:\s['"`])(.*)(['"`])/gi, | ||
`$1${newSelector}$3`, | ||
); | ||
} | ||
|
||
set templateUrl(newUrl: string) { | ||
this.rawFileContent = this.rawFileContent.replace( | ||
/(templateUrl:\s['"`])(.*)(['"`])/gi, | ||
`$1${newUrl}$3`, | ||
); | ||
} | ||
|
||
set styleUrls(newUrls: string[] | readonly string[]) { | ||
this.rawFileContent = this.rawFileContent.replace( | ||
/(styleUrls:\s)(\[.*\])/gi, | ||
`$1${JSON.stringify(newUrls)}`, | ||
); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
apps/demo/src/app/pages/stackblitz/classes/ts-file-module.parser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {TsFileParser} from './ts-file.parser'; | ||
|
||
export class TsFileModuleParser extends TsFileParser { | ||
addDeclaration(entity: string): void { | ||
this.rawFileContent = this.rawFileContent.replace( | ||
`declarations: [`, | ||
`declarations: [${entity}, `, | ||
); | ||
} | ||
|
||
addModuleImport(entity: string): void { | ||
this.rawFileContent = this.rawFileContent.replace( | ||
`imports: [`, | ||
`imports: [\n${entity}, `, | ||
); | ||
} | ||
|
||
hasDeclarationEntity(entity: string): boolean { | ||
const [, declarations = ``] = | ||
this.rawFileContent.match(/(?:declarations:\s\[)(.*)(?:\])/i) || []; | ||
|
||
return declarations.includes(entity); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
apps/demo/src/app/pages/stackblitz/classes/ts-file.parser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import {TuiTsParserException} from '@taiga-ui/cdk'; | ||
|
||
export class TsFileParser { | ||
get className(): string { | ||
const [, className] = this.rawFileContent.match(/(?:export class\s)(\w*)/i) || []; | ||
|
||
return className || ``; | ||
} | ||
|
||
set className(newClassName: string) { | ||
this.rawFileContent = this.rawFileContent.replace( | ||
/(export class\s)(\w*)/i, | ||
`$1${newClassName}`, | ||
); | ||
} | ||
|
||
get hasNgModule(): boolean { | ||
return this.rawFileContent.includes(`@NgModule`); | ||
} | ||
|
||
get hasNgComponent(): boolean { | ||
return this.rawFileContent.includes(`@Component`); | ||
} | ||
|
||
constructor(protected rawFileContent: string) { | ||
const classesInside = rawFileContent.match(/export class/gi) || []; | ||
|
||
if (classesInside.length > 1) { | ||
throw new TuiTsParserException(); | ||
} | ||
|
||
this.replaceMetaAssets(); | ||
} | ||
|
||
addImport(entity: string, packageOrPath: string): void { | ||
const fromName = packageOrPath.replace(`.ts`, ``); | ||
|
||
this.rawFileContent = this.rawFileContent.includes(fromName) | ||
? this.addIntoExistingImport(entity, fromName) | ||
: `import {${entity}} from '${fromName}';\n${this.rawFileContent};`; | ||
} | ||
|
||
toString(): string { | ||
return this.rawFileContent; | ||
} | ||
|
||
private addIntoExistingImport(entity: string, packageName: string): string { | ||
const packageImportsRegex = new RegExp( | ||
`(?:import\\s?\\{\\r?\\n?)(?:(?:.*),\\r?\\n?)*?(?:.*?)\\r?\\n?} from (?:'|")${packageName}(?:'|");`, | ||
`gm`, | ||
); | ||
|
||
return this.rawFileContent.replace(packageImportsRegex, parsed => | ||
parsed.includes(entity) ? parsed : parsed.replace(`{`, `{${entity}, `), | ||
); | ||
} | ||
|
||
/** | ||
* @description: | ||
* The 'import.meta' doesn't support on Stackblitz | ||
*/ | ||
private replaceMetaAssets(): void { | ||
this.rawFileContent = this.rawFileContent.replace( | ||
`import {assets} from '@demo/utils';\n`, | ||
``, | ||
); | ||
|
||
this.rawFileContent = this.rawFileContent.replace( | ||
`assets\``, | ||
`\`https://taiga-ui.dev/assets`, | ||
); | ||
} | ||
} |
Oops, something went wrong.