-
Notifications
You must be signed in to change notification settings - Fork 571
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1385 from xaviPastHubs/patch-1
feat: add accessControl field to Android Compose template
- Loading branch information
Showing
7 changed files
with
191 additions
and
14 deletions.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
'style-dictionary': patch | ||
--- | ||
|
||
add accessControl field to Android Compose template |
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
48 changes: 48 additions & 0 deletions
48
__tests__/formats/__snapshots__/androidCompose.test.snap.js
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,48 @@ | ||
/* @web/test-runner snapshot v1 */ | ||
export const snapshots = {}; | ||
|
||
snapshots["formats compose/object should match default snapshot"] = | ||
` | ||
// Do not edit directly, this file was auto-generated. | ||
package | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.* | ||
object { | ||
/** comment */ | ||
val color-base-red = #ff0000 | ||
val color-white = #ffffff | ||
val size-font-large = 18rem | ||
val size-font-small = 12rem | ||
} | ||
`; | ||
/* end snapshot formats compose/object should match default snapshot */ | ||
|
||
snapshots["formats compose/object with options overrides should match snapshot"] = | ||
` | ||
// Do not edit directly, this file was auto-generated. | ||
package com.example.tokens | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.Brush | ||
import androidx.compose.ui.unit.* | ||
public data object MyObject { | ||
/** comment */ | ||
public val color-base-red = #ff0000 | ||
public val color-white = #ffffff | ||
public val size-font-large = 18rem | ||
public val size-font-small = 12rem | ||
} | ||
`; | ||
/* end snapshot formats compose/object with options overrides should match snapshot */ | ||
|
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,114 @@ | ||
/* | ||
* Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with | ||
* the License. A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
import { expect } from 'chai'; | ||
import formats from '../../lib/common/formats.js'; | ||
import createFormatArgs from '../../lib/utils/createFormatArgs.js'; | ||
import flattenTokens from '../../lib/utils/flattenTokens.js'; | ||
|
||
const tokens = { | ||
size: { | ||
font: { | ||
small: { | ||
value: '12rem', | ||
type: 'fontSize', | ||
original: { | ||
value: '12px', | ||
}, | ||
name: 'size-font-small', | ||
path: ['size', 'font', 'small'], | ||
}, | ||
large: { | ||
value: '18rem', | ||
type: 'fontSize', | ||
original: { | ||
value: '18px', | ||
}, | ||
name: 'size-font-large', | ||
path: ['size', 'font', 'large'], | ||
}, | ||
}, | ||
}, | ||
color: { | ||
base: { | ||
red: { | ||
value: '#ff0000', | ||
type: 'color', | ||
comment: 'comment', | ||
original: { | ||
value: '#FF0000', | ||
comment: 'comment', | ||
}, | ||
name: 'color-base-red', | ||
path: ['color', 'base', 'red'], | ||
}, | ||
}, | ||
white: { | ||
value: '#ffffff', | ||
type: 'color', | ||
original: { | ||
value: '#ffffff', | ||
}, | ||
name: 'color-white', | ||
path: ['color', 'white'], | ||
}, | ||
}, | ||
}; | ||
|
||
const format = formats['compose/object']; | ||
const file = { | ||
destination: '__output/', | ||
format: 'compose/object', | ||
}; | ||
|
||
describe('formats', () => { | ||
describe(`compose/object`, () => { | ||
it('should match default snapshot', async () => { | ||
const f = await format( | ||
createFormatArgs({ | ||
dictionary: { tokens, allTokens: flattenTokens(tokens) }, | ||
file, | ||
platform: {}, | ||
}), | ||
{}, | ||
file, | ||
); | ||
await expect(f).to.matchSnapshot(); | ||
}); | ||
|
||
it('with options overrides should match snapshot', async () => { | ||
const file = { | ||
options: { | ||
import: [ | ||
'androidx.compose.ui.graphics.Color', | ||
'androidx.compose.ui.graphics.Brush', | ||
'androidx.compose.ui.unit.*', | ||
], | ||
className: 'MyObject', | ||
packageName: 'com.example.tokens', | ||
accessControl: 'public', | ||
objectType: 'data', | ||
}, | ||
}; | ||
const f = await format( | ||
createFormatArgs({ | ||
dictionary: { tokens, allTokens: flattenTokens(tokens) }, | ||
file, | ||
platform: {}, | ||
}), | ||
{}, | ||
file, | ||
); | ||
await expect(f).to.matchSnapshot(); | ||
}); | ||
}); | ||
}); |
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