2021-10-31 17:27:35 +00:00
|
|
|
/*
|
2023-02-14 19:46:46 +00:00
|
|
|
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
2021-10-31 17:27:35 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibWeb/CSS/PreferredColorScheme.h>
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
2023-02-14 19:46:46 +00:00
|
|
|
PreferredColorScheme preferred_color_scheme_from_string(StringView value)
|
2021-10-31 17:27:35 +00:00
|
|
|
{
|
2023-03-10 08:48:54 +01:00
|
|
|
if (value.equals_ignoring_ascii_case("light"sv))
|
2021-10-31 17:27:35 +00:00
|
|
|
return PreferredColorScheme::Light;
|
2023-03-10 08:48:54 +01:00
|
|
|
if (value.equals_ignoring_ascii_case("dark"sv))
|
2021-10-31 17:27:35 +00:00
|
|
|
return PreferredColorScheme::Dark;
|
|
|
|
return PreferredColorScheme::Auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
StringView preferred_color_scheme_to_string(PreferredColorScheme value)
|
|
|
|
{
|
|
|
|
switch (value) {
|
|
|
|
case PreferredColorScheme::Light:
|
|
|
|
return "light"sv;
|
|
|
|
case PreferredColorScheme::Dark:
|
|
|
|
return "dark"sv;
|
|
|
|
case PreferredColorScheme::Auto:
|
|
|
|
return "auto"sv;
|
|
|
|
}
|
|
|
|
VERIFY_NOT_REACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|