Skip to content

Commit

Permalink
fix: lint issues/ typos
Browse files Browse the repository at this point in the history
  • Loading branch information
jcassidyav committed Nov 27, 2023
1 parent 722eaf1 commit 7d3f3ea
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 48 deletions.
4 changes: 2 additions & 2 deletions content/core/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ Returns whether the system appearance is `dark`, `light` or `null`(for iOS <= 11

## API References

| Name | Type |
| ------------------------------------------------------------------------------------------------- | -------- |
| Name | Type |
| -------------------------------------------------------------------------------- | -------- |
| [@nativescript/core/application](https://docs.nativescript.org/api/#application) | `Module` |

## Native Component
Expand Down
12 changes: 6 additions & 6 deletions content/core/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The following steps outline the basic usage of the Trace class. Steps 1 and 2 sh
// Or, add multiple categories.
Trace.addCategories('categ1, categ2')
// Or, combine the default Trace categories with your own additional categories.
Trace.setCategories(Trace.categories.concat("category1","category2"))
Trace.setCategories(Trace.categories.concat('category1', 'category2'))
```

When writing a trace message, if you don't set a category, or if the category you pass to `Trace.write()` has not been previously added using the above commands, the message will not be written.
Expand All @@ -37,14 +37,14 @@ The following steps outline the basic usage of the Trace class. Steps 1 and 2 sh
// Add a trace message
Trace.write('This is a simple message', 'category')
// Add a trace message with a given message type
Trace.write('This is an error message', 'category2'. Trace.messageType.error)
Trace.write('This is an error message', 'category2', Trace.messageType.error)
```

4. When your app is in production, you can now simply disable tracing and all `Trace.write()` calls will be ignored.

```ts
if (!__DEV__) {
Trace.disable()
Trace.disable()
}
```

Expand Down Expand Up @@ -74,7 +74,7 @@ const TimestampTraceWriter: TraceWriter = {
console.log(`${timestamp} [${category}] ${message}`)
return
}
}
},
}
```

Expand Down Expand Up @@ -284,6 +284,6 @@ You may optionally provide a type to indicate the severity.

## API References

| Name | Type |
| ------------------------------------------------------------------------------------- | -------- |
| Name | Type |
| ----------------------------------------------------------------------------- | -------- |
| [@nativescript/core/trace](https://docs.nativescript.org/api/namespace/Trace) | `Module` |
3 changes: 0 additions & 3 deletions content/guide/accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,3 @@ The following are the platforms tools for debugging accessibility in your app:

- iOS: [Accessibility Inspect](https://developer.apple.com/library/archive/documentation/Accessibility/Conceptual/AccessibilityMacOSX/OSXAXTestingApps.html)
- Android: [Test your app's accessibility](https://developer.android.com/guide/topics/ui/accessibility/testing)



88 changes: 56 additions & 32 deletions content/guide/property-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,53 +119,77 @@ To create a shorthand property, use the `CssProperty` class to define all the pr
Here's an example of how the margin shorthand is implemented:

```ts
const marginProperty = new ShorthandProperty<Style, string | CoreTypes.PercentLengthType>({
name: 'margin',
cssName: 'margin',
getter: function (this: Style) {
if (PercentLength.equals(this.marginTop, this.marginRight) && PercentLength.equals(this.marginTop, this.marginBottom) && PercentLength.equals(this.marginTop, this.marginLeft)) {
return this.marginTop;
}

return `${PercentLength.convertToString(this.marginTop)} ${PercentLength.convertToString(this.marginRight)} ${PercentLength.convertToString(this.marginBottom)} ${PercentLength.convertToString(this.marginLeft)}`;
},
converter: convertToMargins,
});
marginProperty.register(Style);
const marginProperty = new ShorthandProperty<
Style,
string | CoreTypes.PercentLengthType
>({
name: 'margin',
cssName: 'margin',
getter: function (this: Style) {
if (
PercentLength.equals(this.marginTop, this.marginRight) &&
PercentLength.equals(this.marginTop, this.marginBottom) &&
PercentLength.equals(this.marginTop, this.marginLeft)
) {
return this.marginTop
}

return `${PercentLength.convertToString(
this.marginTop
)} ${PercentLength.convertToString(
this.marginRight
)} ${PercentLength.convertToString(
this.marginBottom
)} ${PercentLength.convertToString(this.marginLeft)}`
},
converter: convertToMargins,
})
marginProperty.register(Style)
```

### Creating a coercible property

To create a coercible property use the [CoercibleProperty](https://docs.nativescript.org/api/class/CoercibleProperty) class passing it a [CoerciblePropertyOptions](#co) object.

```ts
export const selectedIndexProperty = new CoercibleProperty<SegmentedBar, number>({
name: "selectedIndex", defaultValue: -1,
export const selectedIndexProperty = new CoercibleProperty<
SegmentedBar,
number
>({
name: 'selectedIndex',
defaultValue: -1,
valueChanged: (target, oldValue, newValue) => {
target.notify(<SelectedIndexChangedEventData>{ eventName: SegmentedBar.selectedIndexChangedEvent, object: target, oldIndex: oldValue, newIndex: newValue });
target.notify(<SelectedIndexChangedEventData>{
eventName: SegmentedBar.selectedIndexChangedEvent,
object: target,
oldIndex: oldValue,
newIndex: newValue,
})
},

// in this case the coerce value will change depending on whether the actual number of items
// is more or less than the value we want to apply for selectedIndex
coerceValue: (target, value) => {
let items = target.items;
if (items) {
let max = items.length - 1;
if (value < 0) {
value = 0;
}
if (value > max) {
value = max;
}
} else {
value = -1;
let items = target.items
if (items) {
let max = items.length - 1
if (value < 0) {
value = 0
}
if (value > max) {
value = max
}
} else {
value = -1
}

return value;
return value
},

valueConverter: (v) => parseInt(v)
});
selectedIndexProperty.register(SegmentedBar);
````
valueConverter: (v) => parseInt(v),
})
selectedIndexProperty.register(SegmentedBar)
```

Subsequently, when assigning a value to the property, invoke the `coerce()` method.

Expand Down
6 changes: 3 additions & 3 deletions content/ui/absolute-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ If you need to build more complex UIs with overlapping elements, consider using

### Props

| Name | Type | Description |
| -------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `N/A` | `N/A` | None. |
| Name | Type | Description |
| -------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `N/A` | `N/A` | None. |
| `...Inherited` | `Inherited` | Additional inherited properties not shown. Refer to the [API Reference](https://docs.nativescript.org/api/class/AbsoluteLayout) |

### Children props
Expand Down
4 changes: 2 additions & 2 deletions content/ui/repeater.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ When using `ObservableArray` the repeater will be automatically updated when ite

### API References

| Name | Type |
| ------------------------------------------------------------------------ | ------- |
| Name | Type |
| ------------------------------------------------------------ | ------- |
| [Repeater](https://docs.nativescript.org/api/class/Repeater) | `Class` |

0 comments on commit 7d3f3ea

Please sign in to comment.