Skip to content

Commit

Permalink
Merge pull request #4 from lejard-h/more_snippets
Browse files Browse the repository at this point in the history
More Dart snippets
  • Loading branch information
aadarshadhakalg authored Nov 8, 2020
2 parents 80499fe + 2adab8b commit 864e96e
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 40 deletions.
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@

All notable changes to the "adsnippets" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
## [0.0.6]

- rename `adcomp` to `ad-comp`
- Fix html snippets

- More Dart snippets
| Shortcut | Description |
| ------------- | -------------------------------------- |
| ad-comp-push | Component with OnPush change detection |
| ad-comp-route | Route Component |
| ad-pipe | Pipe |
| ad-directive | Directive |
| ad-route | Route Definition |
| ad-route-lazy | Deferred Route Definition |
| ad-trackBy | Track By function |

## [0.0.5]

- Added Html Code Snippets


## [0.0.4]

- Bug Fixes
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ Angular Dart Snippets Generator.

### Generating Dart Codes

| Shortcut | Description |
| -------- | -------------------------- |
| adcomp | Generate Angular Component |
| Shortcut | Description |
| ------------- | -------------------------------------- |
| ad-comp | Generate Angular Component |
| ad-comp-push | Component with OnPush change detection |
| ad-comp-route | Route Component |
| ad-pipe | Pipe |
| ad-directive | Directive |
| ad-route | Route Definition |
| ad-route-lazy | Deferred Route Definition |
| ad-trackBy | Track By function |

### Template Syntax

Expand Down
73 changes: 39 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
{
"name": "adsnippets",
"displayName": "Angular Dart Snippets",
"description": "A simple Angular Dart snippet extension. Generate boilerplate code for your next Angular Dart Project",
"version": "0.0.5",
"publisher": "aadarshadhakalg",
"repository": {
"type": "git",
"url": "https://github.com/aadarshadhakalg/ADSnippets"
},
"icon": "images/icon.png",
"engines": {
"vscode": "^1.50.0"
},
"keywords": [
"Angular Dart",
"AngularDart",
"Dart"
],
"categories": [
"Snippets"
],
"contributes": {
"snippets": [
{
"language": "dart",
"path": "./snippets/dart-snippets.code-snippets"
},
{
"language": "html",
"path": "./snippets/html-snippets.code-snippets"
}
]
}
}
"name": "adsnippets",
"displayName": "Angular Dart Snippets",
"description": "A simple Angular Dart snippet extension. Generate boilerplate code for your next Angular Dart Project",
"version": "0.0.6",
"publisher": "aadarshadhakalg",
"repository": {
"type": "git",
"url": "https://github.com/aadarshadhakalg/ADSnippets"
},
"icon": "images/icon.png",
"engines": {
"vscode": "^1.50.0"
},
"keywords": [
"Angular Dart",
"AngularDart",
"Dart"
],
"categories": [
"Snippets"
],
"contributes": {
"snippets": [
{
"language": "dart",
"path": "./snippets/dart-snippets.code-snippets"
},
{
"language": "html",
"path": "./snippets/html-snippets.code-snippets"
}
]
},
"__metadata": {
"id": "b6cbe7ae-b78b-4ade-b781-36af16bfa67b",
"publisherDisplayName": "Aadarsha Dhakal",
"publisherId": "f5ca5441-948a-4265-b24e-65e3543ab878"
}
}
122 changes: 121 additions & 1 deletion snippets/dart-snippets.code-snippets
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"ComponentSnippet": {
"Angular Component": {
"prefix": "ad-comp",
"description": "Angular Component",
"body": [
"import 'package:angular/angular.dart';\n",
"@Component(",
Expand All @@ -13,5 +14,124 @@
"class ${3:Name}Component {",
"}",
]
},
"Angular Directive": {
"prefix": "ad-directive",
"description": "Angular Directive",
"body": [
"import 'package:angular/angular.dart';\n",
"@Directive(",
"\tselector: '${1:directiveSelector}',",
"\tproviders: [],",
")",
"class ${3:Name}Directive {",
"\tfinal Element element;",
"",
"\t${3:Name}Directive(this.element);",
"}",
]
},
"Angular Pipe": {
"prefix": "ad-pipe",
"description": "Angular pipe",
"body": [
"import 'package:angular/angular.dart';",
"",
"@Pipe('${1:selectorName}')",
"class ${2:Name}Pipe implements PipeTransform {",
"\ttransform(dynamic value) {",
"\t\t$0",
"\t}",
"}"
]
},
"Angular Component OnPush": {
"prefix": "ad-comp-push",
"description": "Angular Component using OnPush change detection",
"body": [
"import 'package:angular/angular.dart';\n",
"@Component(",
"\tselector: '${1:component-selector}',",
"\ttemplateUrl: '${2:component_path}.html',",
"\tstyleUrls: ['${2:component_path}.css'],",
"\tdirectives: [coreDirectives],",
"\tproviders: [],",
"\tchangeDetection: ChangeDetectionStrategy.OnPush,",
")",
"class ${3:Name}Component {",
"\tfinal ChangeDetectorRef changeDetection;",
"",
"\t${3:Name}Component(this.changeDetection);",
"}",
]
},
"Angular Route Component": {
"prefix": "ad-comp-route",
"description": "Angular Route Component",
"body": [
"import 'package:angular/angular.dart';",
"import 'package:angular_router/angular_router.dart';",
"import '$TM_FILENAME_BASE.template.dart' as template;",
"",
"final ngFactory = template.${1:Name}ComponentNgFactory;",
"",
"@Component(",
"\tselector: '${2:component-selector}',",
"\ttemplateUrl: '${3:component_path}.html',",
"\tstyleUrls: ['${3:component_path}.css'],",
"\tdirectives: [coreDirectives],",
"\tproviders: [],",
")",
"class ${1:Name}Component implements OnActivate, OnDeactivate {",
"",
"\t@override",
"\tvoid onActivate(RouterState previous, RouterState current) {",
"\t\t$0",
"\t}",
"",
"\t@override",
"\tvoid onDeactivate(RouterState current, RouterState next) {",
"\t}",
"",
"}",
]
},
"Angular Route Definition": {
"prefix": "ad-route",
"description": "Angular Route Definition",
"body": [
"import 'package:angular_router/angular_router.dart';",
"import '${1:component_route_path}' as ${2:name}_lib;",
"",
"final ${2:name}Route = RouteDefinition(",
"\tpath: ${3:RoutePath},",
"\tcomponent: ${2:name}_lib.ngFactory,",
");",
]
},
"Angular Route Definition Lazy": {
"prefix": "ad-route-lazy",
"description": "Angular Route Definition Lazy",
"body": [
"import 'package:angular_router/angular_router.dart';",
"import '${1:component_route_path}' deferred as ${2:name}_lib;",
"",
"final ${2:name}Route = RouteDefinition.defer(",
"\tpath: ${3:RoutePath},",
"\tloader: () async {",
"\t\tawait ${2:name}_lib.loadLibrary();",
"\t\treturn ${2:name}_lib.ngFactory;",
"\t},",
");",
]
},
"TrackBy Function": {
"prefix": "ad-trackby",
"description": "TrackBy Function",
"body": [
"${1:trackBy}(int index,, item) {",
"\t$0",
"}"
]
}
}

0 comments on commit 864e96e

Please sign in to comment.