Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added Color abstraction (#251) #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
KoditkarVedant merged 3 commits into notion-dotnet:main from Sphere10:main
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand All @@ -8,6 +9,7 @@ public class SelectOptionSchema
public string Name { get; set; }

[JsonProperty("color")]
public string Color { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
}
}
5 changes: 5 additions & 0 deletions Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand All @@ -15,6 +16,10 @@ public class Info
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
}
Expand Down
5 changes: 5 additions & 0 deletions Src/Notion.Client/Models/Blocks/CalloutBlock.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand All @@ -18,6 +19,10 @@ public class Info
[JsonProperty("icon")]
public IPageIcon Icon { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
}
Expand Down
64 changes: 64 additions & 0 deletions Src/Notion.Client/Models/Blocks/Color.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System.Runtime.Serialization;

namespace Notion.Client
{
public enum Color
{
[EnumMember(Value = "default")]
Default,

[EnumMember(Value = "gray")]
Gray,

[EnumMember(Value = "brown")]
Brown,

[EnumMember(Value = "orange")]
Orange,

[EnumMember(Value = "yellow")]
Yellow,

[EnumMember(Value = "green")]
Green,

[EnumMember(Value = "blue")]
Blue,

[EnumMember(Value = "purple")]
Purple,

[EnumMember(Value = "pink")]
Pink,

[EnumMember(Value = "red")]
Red,

[EnumMember(Value = "gray_background")]
GrayBackground,

[EnumMember(Value = "brown_background")]
BrownBackground,

[EnumMember(Value = "orange_background")]
OrangeBackground,

[EnumMember(Value = "yellow_background")]
YellowBackground,

[EnumMember(Value = "green_background")]
GreenBackground,

[EnumMember(Value = "blue_background")]
BlueBackground,

[EnumMember(Value = "purple_background")]
PurpleBackground,

[EnumMember(Value = "pink_background")]
PinkBackground,

[EnumMember(Value = "red_background")]
RedBackground,
}
}
5 changes: 5 additions & 0 deletions Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand All @@ -16,6 +17,10 @@ public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
}
}
}
5 changes: 5 additions & 0 deletions Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand All @@ -16,6 +17,10 @@ public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
}
}
}
5 changes: 5 additions & 0 deletions Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand All @@ -16,6 +17,10 @@ public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
}
}
}
5 changes: 5 additions & 0 deletions Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand All @@ -15,6 +16,10 @@ public class Info
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
}
Expand Down
5 changes: 5 additions & 0 deletions Src/Notion.Client/Models/Blocks/ParagraphBlock.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand All @@ -15,6 +16,10 @@ public class Info
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
}
Expand Down
5 changes: 5 additions & 0 deletions Src/Notion.Client/Models/Blocks/QuoteBlock.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand All @@ -15,6 +16,10 @@ public class Info
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
}
Expand Down
4 changes: 4 additions & 0 deletions Src/Notion.Client/Models/Blocks/TableOfContentsBlock.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand All @@ -11,6 +12,9 @@ public class TableOfContentsBlock : Block, IColumnChildrenBlock, INonColumnBlock

public class Data
{
[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
}
}
}
5 changes: 5 additions & 0 deletions Src/Notion.Client/Models/Blocks/ToDoBlock.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand All @@ -18,6 +19,10 @@ public class Info
[JsonProperty("checked")]
public bool IsChecked { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
}
Expand Down
5 changes: 5 additions & 0 deletions Src/Notion.Client/Models/Blocks/ToggleBlock.cs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand All @@ -15,6 +16,10 @@ public class Info
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
}
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
Expand Down Expand Up @@ -33,7 +34,8 @@ public class SelectOption
/// Color of the option. Possible values are: "default", "gray", "brown", "red", "orange", "yellow", "green", "blue", "purple", "pink". Defaults to "default".
/// </summary>
[JsonProperty("color")]
public string Color { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
}

public class MultiSelectProperty : Property
Expand Down
4 changes: 2 additions & 2 deletions Src/Notion.Client/Models/Database/RichText/RichTextBase.cs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Annotations
public bool IsCode { get; set; }

[JsonProperty("color")]
// color: Color | BackgroundColor
public string Color { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
}
}
24 changes: 12 additions & 12 deletions Test/Notion.UnitTests/DatabasesClientTests.cs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,17 @@ public async Task CreateDatabaseAsync()
{
new SelectOptionSchema
{
Color = "green",
Color = Color.Green,
Name = "🥦Vegetable"
},
new SelectOptionSchema
{
Color = "red",
Color = Color.Red,
Name = "🍎Fruit"
},
new SelectOptionSchema
{
Color = "yellow",
Color = Color.Yellow,
Name = "💪Protein"
}
}
Expand All @@ -248,17 +248,17 @@ public async Task CreateDatabaseAsync()
option =>
{
option.Name.Should().Be("🥦Vegetable");
option.Color.Should().Be("green");
option.Color.Should().Be(Color.Green);
},
option =>
{
option.Name.Should().Be("🍎Fruit");
option.Color.Should().Be("red");
option.Color.Should().Be(Color.Red);
},
option =>
{
option.Name.Should().Be("💪Protein");
option.Color.Should().Be("yellow");
option.Color.Should().Be(Color.Yellow);
}
);
}
Expand Down Expand Up @@ -303,17 +303,17 @@ public async Task UpdateDatabaseAsync()
{
new SelectOption
{
Color = "green",
Color = Color.Green,
Name = "🥦Vegetables"
},
new SelectOption
{
Color = "red",
Color = Color.Red,
Name = "🍎Fruit"
},
new SelectOption
{
Color = "yellow",
Color = Color.Yellow,
Name = "💪Protein"
}
}
Expand Down Expand Up @@ -346,17 +346,17 @@ public async Task UpdateDatabaseAsync()
option =>
{
option.Name.Should().Be("🥦Vegetables");
option.Color.Should().Be("green");
option.Color.Should().Be(Color.Green);
},
option =>
{
option.Name.Should().Be("🍎Fruit");
option.Color.Should().Be("red");
option.Color.Should().Be(Color.Red);
},
option =>
{
option.Name.Should().Be("💪Protein");
option.Color.Should().Be("yellow");
option.Color.Should().Be(Color.Yellow);
}
);

Expand Down

AltStyle によって変換されたページ (->オリジナル) /